aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-08-08 09:36:04 +0000
committerChristian Grothoff <christian@grothoff.org>2013-08-08 09:36:04 +0000
commit270c6d4acd6de1cb9806b5da2e3d3f46f2a11947 (patch)
treea2cf84725d9ffc28fb530136553a159e6ca8ab85
parent17eabae92ed6b34f8d2ff252be806c0995f02acd (diff)
downloadgnunet-gtk-270c6d4acd6de1cb9806b5da2e3d3f46f2a11947.tar.gz
gnunet-gtk-270c6d4acd6de1cb9806b5da2e3d3f46f2a11947.zip
-fixes to use identity properly in publish dialog
-rw-r--r--contrib/gnunet_fs_gtk_publish_dialog.glade106
-rw-r--r--src/fs/gnunet-fs-gtk_publish-dialog.c291
2 files changed, 273 insertions, 124 deletions
diff --git a/contrib/gnunet_fs_gtk_publish_dialog.glade b/contrib/gnunet_fs_gtk_publish_dialog.glade
index 495df952..89c10207 100644
--- a/contrib/gnunet_fs_gtk_publish_dialog.glade
+++ b/contrib/gnunet_fs_gtk_publish_dialog.glade
@@ -1,6 +1,6 @@
1<?xml version="1.0" encoding="UTF-8"?> 1<?xml version="1.0" encoding="UTF-8"?>
2<interface> 2<interface>
3 <requires lib="gtk+" version="2.20"/> 3 <requires lib="gtk+" version="2.24"/>
4 <!-- interface-naming-policy project-wide --> 4 <!-- interface-naming-policy project-wide -->
5 <object class="GtkTreeStore" id="GNUNET_GTK_file_sharing_publishing_tree_store"> 5 <object class="GtkTreeStore" id="GNUNET_GTK_file_sharing_publishing_tree_store">
6 <columns> 6 <columns>
@@ -22,26 +22,11 @@
22 <column type="guint"/> 22 <column type="guint"/>
23 </columns> 23 </columns>
24 </object> 24 </object>
25 <object class="GtkTreeStore" id="GNUNET_GTK_indentifiers_treestore">
26 <columns>
27 <!-- column-name Identifier -->
28 <column type="gchararray"/>
29 <!-- column-name UpdateIdentifier -->
30 <column type="gchararray"/>
31 <!-- column-name Description -->
32 <column type="gchararray"/>
33 <!-- column-name PathToOriginal -->
34 <column type="gchararray"/>
35 <!-- column-name IdentifierMarkedUp -->
36 <column type="gchararray"/>
37 </columns>
38 </object>
39 <object class="GtkWindow" id="GNUNET_GTK_master_publish_dialog"> 25 <object class="GtkWindow" id="GNUNET_GTK_master_publish_dialog">
40 <property name="height_request">500</property> 26 <property name="height_request">500</property>
41 <property name="can_focus">False</property> 27 <property name="can_focus">False</property>
42 <property name="title" translatable="yes">Publish content on GNUnet</property> 28 <property name="title" translatable="yes">Publish content on GNUnet</property>
43 <property name="window_position">center-on-parent</property> 29 <property name="window_position">center-on-parent</property>
44 <property name="destroy_with_parent">True</property>
45 <signal name="delete-event" handler="GNUNET_GTK_master_publish_dialog_delete_event_cb" swapped="no"/> 30 <signal name="delete-event" handler="GNUNET_GTK_master_publish_dialog_delete_event_cb" swapped="no"/>
46 <child> 31 <child>
47 <object class="GtkVBox" id="GNUNET_GTK_master_publish_dialog_vbox"> 32 <object class="GtkVBox" id="GNUNET_GTK_master_publish_dialog_vbox">
@@ -339,6 +324,30 @@
339 <child> 324 <child>
340 <placeholder/> 325 <placeholder/>
341 </child> 326 </child>
327 <child>
328 <placeholder/>
329 </child>
330 <child>
331 <placeholder/>
332 </child>
333 <child>
334 <placeholder/>
335 </child>
336 <child>
337 <placeholder/>
338 </child>
339 <child>
340 <placeholder/>
341 </child>
342 <child>
343 <placeholder/>
344 </child>
345 <child>
346 <placeholder/>
347 </child>
348 <child>
349 <placeholder/>
350 </child>
342 </object> 351 </object>
343 <packing> 352 <packing>
344 <property name="expand">False</property> 353 <property name="expand">False</property>
@@ -415,16 +424,18 @@ Disabling this is equivalent to pressing the "Remove all Keywords" button before
415 <object class="GtkCheckButton" id="GNUNET_GTK_master_publish_dialog_own_checkbox"> 424 <object class="GtkCheckButton" id="GNUNET_GTK_master_publish_dialog_own_checkbox">
416 <property name="label" translatable="yes">Publish in your own namespace</property> 425 <property name="label" translatable="yes">Publish in your own namespace</property>
417 <property name="visible">True</property> 426 <property name="visible">True</property>
427 <property name="sensitive">False</property>
418 <property name="can_focus">True</property> 428 <property name="can_focus">True</property>
419 <property name="receives_default">False</property> 429 <property name="receives_default">False</property>
420 <property name="tooltip_text" translatable="yes">Sign the publication with your private key (pseudonym), and give it an identifier, under which it will be found in your namespace. 430 <property name="tooltip_text" translatable="yes">Sign the publication with one of your pseudonyms, and give it an identifier, under which it will be found in your namespace.
421Other users will be able to browse anything you publish in your namespace (if you maintain a root element), or get separate files from your namespace by their identifiers, and be assured that these files come from the same (anonymous) publisher.
422 431
423Unless specifically disabled in the configuration file, global namespace publications will also advertise your namespace, if you enable both global and private namespace publication. 432Using a pseudonym that you also use in a different context (i.e. GNS), may allow an adversary to link you to this publication, even if you selected anonymous pubishing.
433Thus, you must keep your pseudonyms for anonymous publishing separate from all other alter egos you may use within GNUnet.
424 434
425Despite all that, private namespace publications are just as anonymous as global namespace publications. 435Once other users discover your namespace, they will be able to get files from your namespace by their identifiers, and be assured that these files all come from the same publisher.
426 436
427Publishing in both global and private namespaces will not double storage requirements for published files.</property> 437Publishing in both global and private namespaces will not double storage requirements for published files.
438</property>
428 <property name="draw_indicator">True</property> 439 <property name="draw_indicator">True</property>
429 <signal name="toggled" handler="GNUNET_GTK_master_publish_dialog_own_checkbox_toggled_cb" swapped="no"/> 440 <signal name="toggled" handler="GNUNET_GTK_master_publish_dialog_own_checkbox_toggled_cb" swapped="no"/>
430 </object> 441 </object>
@@ -435,13 +446,16 @@ Publishing in both global and private namespaces will not double storage require
435 </packing> 446 </packing>
436 </child> 447 </child>
437 <child> 448 <child>
438 <object class="GtkLabel" id="GNUNET_GTK_master_publish_dialog_own_label"> 449 <object class="GtkComboBox" id="GNUNET_GTK_master_publish_dialog_ego_combobox">
439 <property name="visible">True</property> 450 <property name="visible">True</property>
440 <property name="can_focus">False</property> 451 <property name="can_focus">False</property>
441 <property name="label">&lt;filled with the name of selected default namespace&gt;</property> 452 <property name="model">GNUNET_GTK_master_publish_dialog_ego_liststore</property>
453 <property name="has_entry">True</property>
454 <property name="entry_text_column">0</property>
455 <signal name="changed" handler="GNUNET_GTK_master_publish_dialog_ego_combobox_changed_cb" swapped="no"/>
442 </object> 456 </object>
443 <packing> 457 <packing>
444 <property name="expand">False</property> 458 <property name="expand">True</property>
445 <property name="fill">True</property> 459 <property name="fill">True</property>
446 <property name="position">1</property> 460 <property name="position">1</property>
447 </packing> 461 </packing>
@@ -465,6 +479,7 @@ Publishing in both global and private namespaces will not double storage require
465 <object class="GtkLabel" id="GNUNET_GTK_master_publish_dialog_identifier_label"> 479 <object class="GtkLabel" id="GNUNET_GTK_master_publish_dialog_identifier_label">
466 <property name="visible">True</property> 480 <property name="visible">True</property>
467 <property name="can_focus">False</property> 481 <property name="can_focus">False</property>
482 <property name="tooltip_text" translatable="yes">Name under which the publication will appear in your namespace. Equivalent to the keyword that is used when publishing in the global namespace.</property>
468 <property name="xalign">0</property> 483 <property name="xalign">0</property>
469 <property name="label" translatable="yes">Identifier:</property> 484 <property name="label" translatable="yes">Identifier:</property>
470 </object> 485 </object>
@@ -477,6 +492,7 @@ Publishing in both global and private namespaces will not double storage require
477 <child> 492 <child>
478 <object class="GtkEntry" id="GNUNET_GTK_master_publish_dialog_identifier_entry"> 493 <object class="GtkEntry" id="GNUNET_GTK_master_publish_dialog_identifier_entry">
479 <property name="visible">True</property> 494 <property name="visible">True</property>
495 <property name="sensitive">False</property>
480 <property name="can_focus">True</property> 496 <property name="can_focus">True</property>
481 <property name="tooltip_text" translatable="yes">Identifier under which this publication will be found in your namespace. 497 <property name="tooltip_text" translatable="yes">Identifier under which this publication will be found in your namespace.
482Publications made in your namespace use only these identifiers, one per publication, instead of keywords. 498Publications made in your namespace use only these identifiers, one per publication, instead of keywords.
@@ -505,6 +521,7 @@ Type in an identifier, or select one of the update identifiers (from previous up
505 <object class="GtkExpander" id="GNUNET_GTK_master_publish_dialog_previous_identifiers_expander"> 521 <object class="GtkExpander" id="GNUNET_GTK_master_publish_dialog_previous_identifiers_expander">
506 <property name="visible">True</property> 522 <property name="visible">True</property>
507 <property name="can_focus">True</property> 523 <property name="can_focus">True</property>
524 <property name="tooltip_text" translatable="yes">Here you can find a list of previous publications you made in this namespace. This may be convenient if you want to publish an update.</property>
508 <child> 525 <child>
509 <placeholder/> 526 <placeholder/>
510 </child> 527 </child>
@@ -532,7 +549,7 @@ Type in an identifier, or select one of the update identifiers (from previous up
532 <object class="GtkTreeView" id="GNUNET_GTK_master_publish_dialog_previous_identifiers_treeview"> 549 <object class="GtkTreeView" id="GNUNET_GTK_master_publish_dialog_previous_identifiers_treeview">
533 <property name="visible">True</property> 550 <property name="visible">True</property>
534 <property name="can_focus">True</property> 551 <property name="can_focus">True</property>
535 <property name="model">GNUNET_GTK_indentifiers_treestore</property> 552 <property name="model">GNUNET_GTK_update_identifiers_treestore</property>
536 <property name="headers_clickable">False</property> 553 <property name="headers_clickable">False</property>
537 <property name="expander_column">GNUNET_GTK_master_publish_dialog_previous_identifiers_treeview_id_column</property> 554 <property name="expander_column">GNUNET_GTK_master_publish_dialog_previous_identifiers_treeview_id_column</property>
538 <property name="enable_search">False</property> 555 <property name="enable_search">False</property>
@@ -590,9 +607,12 @@ Type in an identifier, or select one of the update identifiers (from previous up
590 <object class="GtkCheckButton" id="GNUNET_GTK_master_publish_dialog_updateable_checkbox"> 607 <object class="GtkCheckButton" id="GNUNET_GTK_master_publish_dialog_updateable_checkbox">
591 <property name="label" translatable="yes">Make publication updateable</property> 608 <property name="label" translatable="yes">Make publication updateable</property>
592 <property name="visible">True</property> 609 <property name="visible">True</property>
610 <property name="sensitive">False</property>
593 <property name="can_focus">True</property> 611 <property name="can_focus">True</property>
594 <property name="receives_default">False</property> 612 <property name="receives_default">False</property>
595 <property name="tooltip_text" translatable="yes">Enable and specify an update identifier to make this publication updateable.</property> 613 <property name="tooltip_text" translatable="yes">With the update mechanism, you can publish updates to a file that will be automatically located when a users searches for the original identifier.
614
615To enable updates, you must check this box and specify an update identifier.</property>
596 <property name="draw_indicator">True</property> 616 <property name="draw_indicator">True</property>
597 <signal name="toggled" handler="GNUNET_GTK_master_publish_dialog_updateable_checkbox_toggled_cb" swapped="no"/> 617 <signal name="toggled" handler="GNUNET_GTK_master_publish_dialog_updateable_checkbox_toggled_cb" swapped="no"/>
598 </object> 618 </object>
@@ -620,6 +640,7 @@ Type in an identifier, or select one of the update identifiers (from previous up
620 <object class="GtkLabel" id="GNUNET_GTK_master_publish_dialog_update_id_label"> 640 <object class="GtkLabel" id="GNUNET_GTK_master_publish_dialog_update_id_label">
621 <property name="visible">True</property> 641 <property name="visible">True</property>
622 <property name="can_focus">False</property> 642 <property name="can_focus">False</property>
643 <property name="tooltip_text" translatable="yes">Identifier under which you "promise" to publish an update to this publication at a later time.</property>
623 <property name="label" translatable="yes">Update identifier:</property> 644 <property name="label" translatable="yes">Update identifier:</property>
624 </object> 645 </object>
625 <packing> 646 <packing>
@@ -631,6 +652,7 @@ Type in an identifier, or select one of the update identifiers (from previous up
631 <child> 652 <child>
632 <object class="GtkEntry" id="GNUNET_GTK_master_publish_dialog_update_id_entry"> 653 <object class="GtkEntry" id="GNUNET_GTK_master_publish_dialog_update_id_entry">
633 <property name="visible">True</property> 654 <property name="visible">True</property>
655 <property name="sensitive">False</property>
634 <property name="can_focus">True</property> 656 <property name="can_focus">True</property>
635 <property name="tooltip_text" translatable="yes">Identifier under which the updated version will be published later. 657 <property name="tooltip_text" translatable="yes">Identifier under which the updated version will be published later.
636GNUnet clients will use it to try to find updated version of this publication automatically. 658GNUnet clients will use it to try to find updated version of this publication automatically.
@@ -746,6 +768,33 @@ Note that meta data is unaffected when using this function.</property>
746 </object> 768 </object>
747 </child> 769 </child>
748 </object> 770 </object>
771 <object class="GtkListStore" id="GNUNET_GTK_master_publish_dialog_ego_liststore">
772 <columns>
773 <!-- column-name name -->
774 <column type="gchararray"/>
775 <!-- column-name ego -->
776 <column type="gpointer"/>
777 </columns>
778 </object>
779 <object class="GtkTreeStore" id="GNUNET_GTK_update_identifiers_treestore">
780 <columns>
781 <!-- column-name Identifier -->
782 <column type="gchararray"/>
783 <!-- column-name UpdateIdentifier -->
784 <column type="gchararray"/>
785 <!-- column-name Description -->
786 <column type="gchararray"/>
787 <!-- column-name PathToOriginal -->
788 <column type="gchararray"/>
789 <!-- column-name IdentifierMarkedUp -->
790 <column type="gchararray"/>
791 </columns>
792 </object>
793 <object class="GtkImage" id="left_stock_image">
794 <property name="visible">True</property>
795 <property name="can_focus">False</property>
796 <property name="stock">gtk-go-back</property>
797 </object>
749 <object class="GtkImage" id="new_stock_image"> 798 <object class="GtkImage" id="new_stock_image">
750 <property name="visible">True</property> 799 <property name="visible">True</property>
751 <property name="can_focus">False</property> 800 <property name="can_focus">False</property>
@@ -756,11 +805,6 @@ Note that meta data is unaffected when using this function.</property>
756 <property name="can_focus">False</property> 805 <property name="can_focus">False</property>
757 <property name="stock">gtk-go-forward</property> 806 <property name="stock">gtk-go-forward</property>
758 </object> 807 </object>
759 <object class="GtkImage" id="left_stock_image">
760 <property name="visible">True</property>
761 <property name="can_focus">False</property>
762 <property name="stock">gtk-go-back</property>
763 </object>
764 <object class="GtkSizeGroup" id="GNUNET_GTK_master_publish_dialog_labels_sizegroup"> 808 <object class="GtkSizeGroup" id="GNUNET_GTK_master_publish_dialog_labels_sizegroup">
765 <widgets> 809 <widgets>
766 <widget name="GNUNET_GTK_master_publish_dialog_identifier_label"/> 810 <widget name="GNUNET_GTK_master_publish_dialog_identifier_label"/>
diff --git a/src/fs/gnunet-fs-gtk_publish-dialog.c b/src/fs/gnunet-fs-gtk_publish-dialog.c
index 975db8c0..ffca4a33 100644
--- a/src/fs/gnunet-fs-gtk_publish-dialog.c
+++ b/src/fs/gnunet-fs-gtk_publish-dialog.c
@@ -119,6 +119,25 @@ enum IDENTIFIERS_ModelColumns
119 119
120 120
121/** 121/**
122 * The columns in the "GNUNET_GTK_master_publish_dialog_ego_liststore"
123 */
124enum EGO_ModelColumns
125 {
126
127 /**
128 * A gchararray.
129 */
130 EGO_MC_NAME = 0,
131
132 /**
133 * A 'struct GNUNET_IDENTIFIER_Ego'.
134 */
135 EGO_MC_EGO = 1
136
137 };
138
139
140/**
122 * Context we create when we are scanning a directory. 141 * Context we create when we are scanning a directory.
123 */ 142 */
124struct AddDirClientContext; 143struct AddDirClientContext;
@@ -129,10 +148,16 @@ struct AddDirClientContext;
129 */ 148 */
130struct MainPublishingDialogContext 149struct MainPublishingDialogContext
131{ 150{
151
132 /** 152 /**
133 * Main builder for the publishing dialog. 153 * Main builder for the publishing dialog.
134 */ 154 */
135 GtkBuilder *builder; 155 GtkBuilder *builder;
156
157 /**
158 * Connection to the identity service.
159 */
160 struct GNUNET_IDENTITY_Handle *identity;
136 161
137 /** 162 /**
138 * Handle to the main window of the publishing dialog. 163 * Handle to the main window of the publishing dialog.
@@ -195,12 +220,6 @@ struct MainPublishingDialogContext
195 GtkWidget *own_checkbox; 220 GtkWidget *own_checkbox;
196 221
197 /** 222 /**
198 * The label that shows name of the default namespace (if no default
199 * namespace is selected, shows appropriate message).
200 */
201 GtkWidget *own_label;
202
203 /**
204 * Treeview that shows previously-used identifiers and possible update IDs. 223 * Treeview that shows previously-used identifiers and possible update IDs.
205 */ 224 */
206 GtkTreeView *identifiers_treeview; 225 GtkTreeView *identifiers_treeview;
@@ -451,8 +470,10 @@ update_selectivity_execute_cancel (struct MainPublishingDialogContext *ctx)
451 their windows are closed */ 470 their windows are closed */
452 if ( (gtk_tree_model_get_iter_first (ctx->file_info_treemodel, &iter)) && 471 if ( (gtk_tree_model_get_iter_first (ctx->file_info_treemodel, &iter)) &&
453 (pub_in_global || pub_in_own) && 472 (pub_in_global || pub_in_own) &&
454 ((!pub_in_own) || ((NULL != ns_id) && ('\0' != ns_id[0]))) && 473 ((!pub_in_own) || ( (NULL != ctx->ns) &&
455 (ctx->adddir_head == NULL) ) 474 (NULL != ns_id) &&
475 ('\0' != ns_id[0])) ) &&
476 (NULL == ctx->adddir_head) )
456 gtk_widget_set_sensitive (ctx->execute_button, TRUE); 477 gtk_widget_set_sensitive (ctx->execute_button, TRUE);
457 else 478 else
458 gtk_widget_set_sensitive (ctx->execute_button, FALSE); 479 gtk_widget_set_sensitive (ctx->execute_button, FALSE);
@@ -464,6 +485,7 @@ update_selectivity_execute_cancel (struct MainPublishingDialogContext *ctx)
464 gtk_widget_set_sensitive (ctx->cancel_button, FALSE); 485 gtk_widget_set_sensitive (ctx->cancel_button, FALSE);
465} 486}
466 487
488
467/** 489/**
468 * Update selectivity of up/down/left/right buttons in the master dialog. 490 * Update selectivity of up/down/left/right buttons in the master dialog.
469 * 491 *
@@ -684,7 +706,7 @@ copy_entry (struct MainPublishingDialogContext *ctx, GtkTreeModel * tm, GtkTreeI
684 copy_entry (ctx, tm, &child, &cnewpos, GNUNET_NO); 706 copy_entry (ctx, tm, &child, &cnewpos, GNUNET_NO);
685 path = gtk_tree_row_reference_get_path (crr); 707 path = gtk_tree_row_reference_get_path (crr);
686 gtk_tree_row_reference_free (crr); 708 gtk_tree_row_reference_free (crr);
687 GNUNET_assert (TRUE == gtk_tree_model_get_iter (tm, &child, path)); 709 GNUNET_assert (gtk_tree_model_get_iter (tm, &child, path));
688 gtk_tree_path_free (path); 710 gtk_tree_path_free (path);
689 } 711 }
690 while (gtk_tree_model_iter_next (tm, &child)); 712 while (gtk_tree_model_iter_next (tm, &child));
@@ -696,7 +718,7 @@ copy_entry (struct MainPublishingDialogContext *ctx, GtkTreeModel * tm, GtkTreeI
696 path = gtk_tree_row_reference_get_path (rr); 718 path = gtk_tree_row_reference_get_path (rr);
697 gtk_tree_row_reference_free (rr); 719 gtk_tree_row_reference_free (rr);
698 gtk_tree_view_expand_to_path (ctx->file_info_treeview, path); 720 gtk_tree_view_expand_to_path (ctx->file_info_treeview, path);
699 GNUNET_assert (TRUE == gtk_tree_model_get_iter (tm, newpos, path)); 721 GNUNET_assert (gtk_tree_model_get_iter (tm, newpos, path));
700 gtk_tree_path_free (path); 722 gtk_tree_path_free (path);
701 gtk_tree_selection_select_iter (ctx->file_info_selection, newpos); 723 gtk_tree_selection_select_iter (ctx->file_info_selection, newpos);
702 update_selectivity_edit (ctx); 724 update_selectivity_edit (ctx);
@@ -2039,7 +2061,7 @@ close_master_publish_dialog (struct MainPublishingDialogContext *ctx)
2039 } 2061 }
2040 while (gtk_tree_model_iter_next (ctx->file_info_treemodel, &iter)); 2062 while (gtk_tree_model_iter_next (ctx->file_info_treemodel, &iter));
2041 gtk_tree_store_clear (GTK_TREE_STORE (ctx->file_info_treemodel)); 2063 gtk_tree_store_clear (GTK_TREE_STORE (ctx->file_info_treemodel));
2042 2064 GNUNET_IDENTITY_disconnect (ctx->identity);
2043 gtk_widget_destroy (GTK_WIDGET (ctx->master_pubdialog)); 2065 gtk_widget_destroy (GTK_WIDGET (ctx->master_pubdialog));
2044 g_object_unref (G_OBJECT (ctx->builder)); 2066 g_object_unref (G_OBJECT (ctx->builder));
2045 GNUNET_free_non_null (ctx->ns_name); 2067 GNUNET_free_non_null (ctx->ns_name);
@@ -2067,16 +2089,20 @@ close_master_publish_dialog (struct MainPublishingDialogContext *ctx)
2067 */ 2089 */
2068static int 2090static int
2069insert_advertisement (void *cls, struct GNUNET_FS_FileInformation *fi, 2091insert_advertisement (void *cls, struct GNUNET_FS_FileInformation *fi,
2070 uint64_t length, struct GNUNET_CONTAINER_MetaData *meta, 2092 uint64_t length,
2071 struct GNUNET_FS_Uri **uri, 2093 struct GNUNET_CONTAINER_MetaData *meta,
2072 struct GNUNET_FS_BlockOptions *bo, int *do_index, 2094 struct GNUNET_FS_Uri **uri,
2073 void **client_info) 2095 struct GNUNET_FS_BlockOptions *bo,
2096 int *do_index,
2097 void **client_info)
2074{ 2098{
2075 struct MainPublishingDialogContext *ctx = cls; 2099 struct MainPublishingDialogContext *ctx = cls;
2076 struct GNUNET_CRYPTO_EccPublicKey pub; 2100 struct GNUNET_CRYPTO_EccPublicKey pub;
2077 struct GNUNET_FS_Uri *sks_uri; 2101 struct GNUNET_FS_Uri *sks_uri;
2078 char *sks_uri_string; 2102 char *sks_uri_string;
2079 2103
2104 if (NULL == ctx->ns)
2105 return GNUNET_SYSERR;
2080 GNUNET_IDENTITY_ego_get_public_key (ctx->ns, &pub); 2106 GNUNET_IDENTITY_ego_get_public_key (ctx->ns, &pub);
2081 sks_uri = GNUNET_FS_uri_sks_create (&pub, "/"); 2107 sks_uri = GNUNET_FS_uri_sks_create (&pub, "/");
2082 sks_uri_string = GNUNET_FS_uri_to_string (sks_uri); 2108 sks_uri_string = GNUNET_FS_uri_to_string (sks_uri);
@@ -2085,8 +2111,10 @@ insert_advertisement (void *cls, struct GNUNET_FS_FileInformation *fi,
2085 return GNUNET_SYSERR; 2111 return GNUNET_SYSERR;
2086 2112
2087 GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet>", 2113 GNUNET_CONTAINER_meta_data_insert (meta, "<gnunet>",
2088 EXTRACTOR_METATYPE_URI, EXTRACTOR_METAFORMAT_UTF8, 2114 EXTRACTOR_METATYPE_URI, EXTRACTOR_METAFORMAT_UTF8,
2089 "text/plain", sks_uri_string, strlen (sks_uri_string) + 1); 2115 "text/plain",
2116 sks_uri_string,
2117 strlen (sks_uri_string) + 1);
2090 GNUNET_free (sks_uri_string); 2118 GNUNET_free (sks_uri_string);
2091 return GNUNET_SYSERR; 2119 return GNUNET_SYSERR;
2092} 2120}
@@ -2175,7 +2203,6 @@ GNUNET_GTK_master_publish_dialog_execute_button_clicked_cb (GtkButton * button,
2175 fi = get_file_information (ctx->file_info_treemodel, &iter); 2203 fi = get_file_information (ctx->file_info_treemodel, &iter);
2176 if (do_global && do_own && !disable_ads_insertion) 2204 if (do_global && do_own && !disable_ads_insertion)
2177 GNUNET_FS_file_information_inspect (fi, insert_advertisement, ctx); 2205 GNUNET_FS_file_information_inspect (fi, insert_advertisement, ctx);
2178 /* FIXME-FEATURE-BUG-MINOR: should we convert namespace id and uid from UTF8? */
2179 GNUNET_FS_publish_start (GNUNET_FS_GTK_get_fs_handle (), 2206 GNUNET_FS_publish_start (GNUNET_FS_GTK_get_fs_handle (),
2180 fi, 2207 fi,
2181 GNUNET_IDENTITY_ego_get_private_key (ns), 2208 GNUNET_IDENTITY_ego_get_private_key (ns),
@@ -2356,7 +2383,9 @@ expander_callback (GObject *object,
2356 2383
2357 g_value_init (&gv, G_TYPE_BOOLEAN); 2384 g_value_init (&gv, G_TYPE_BOOLEAN);
2358 g_value_set_boolean (&gv, expanded); 2385 g_value_set_boolean (&gv, expanded);
2359 gtk_container_child_set_property (GTK_CONTAINER (ctx->vpaned), ctx->bottom_frame, "resize", &gv); 2386 gtk_container_child_set_property (GTK_CONTAINER (ctx->vpaned),
2387 ctx->bottom_frame,
2388 "resize", &gv);
2360 paned_pos = gtk_paned_get_position (GTK_PANED (ctx->vpaned)); 2389 paned_pos = gtk_paned_get_position (GTK_PANED (ctx->vpaned));
2361 paned_pos = paned_pos + (scrolled_allocation.height * (expanded ? -1 : 1)); 2390 paned_pos = paned_pos + (scrolled_allocation.height * (expanded ? -1 : 1));
2362 gtk_paned_set_position (GTK_PANED (ctx->vpaned), paned_pos); 2391 gtk_paned_set_position (GTK_PANED (ctx->vpaned), paned_pos);
@@ -2449,7 +2478,9 @@ add_updateable_to_ts (void *cls, const char *last_id,
2449 urilen = 0; 2478 urilen = 0;
2450 2479
2451 mdbuf = NULL; 2480 mdbuf = NULL;
2452 mdsize = GNUNET_CONTAINER_meta_data_serialize (last_meta, &mdbuf, 64*1024, GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL); 2481 mdsize = GNUNET_CONTAINER_meta_data_serialize (last_meta,
2482 &mdbuf, 64*1024,
2483 GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL);
2453 if (0 > mdsize) 2484 if (0 > mdsize)
2454 mdsize = 0; 2485 mdsize = 0;
2455 2486
@@ -2535,18 +2566,19 @@ add_updateable_to_ts (void *cls, const char *last_id,
2535 next_id, 2566 next_id,
2536 &add_updateable_to_ts, 2567 &add_updateable_to_ts,
2537 &sc); 2568 &sc);
2538 if ((sc.update_called == GNUNET_NO) && (next_id != NULL) && 2569 if ((sc.update_called == GNUNET_NO) &&
2570 (NULL != next_id) &&
2539 (strlen (next_id) > 0)) 2571 (strlen (next_id) > 0))
2540 { 2572 {
2541 /* add leaf */ 2573 /* add leaf */
2542 displaytext = g_strdup_printf ("<b>%s</b>", next_id); 2574 displaytext = g_strdup_printf ("<b>%s</b>", next_id);
2543 gtk_tree_store_insert_with_values (uc->ts, &titer, &iter, G_MAXINT, 2575 gtk_tree_store_insert_with_values (uc->ts, &titer, &iter, G_MAXINT,
2544 IDENTIFIERS_MC_ID, next_id, 2576 IDENTIFIERS_MC_ID, next_id,
2545 IDENTIFIERS_MC_UPDATE_ID, NULL, 2577 IDENTIFIERS_MC_UPDATE_ID, NULL,
2546 IDENTIFIERS_MC_DESCRIPTION, NULL, 2578 IDENTIFIERS_MC_DESCRIPTION, NULL,
2547 IDENTIFIERS_MC_PATH_TO_ORIGINAL, NULL, 2579 IDENTIFIERS_MC_PATH_TO_ORIGINAL, NULL,
2548 IDENTIFIERS_MC_ID_MARKED_UP, displaytext, 2580 IDENTIFIERS_MC_ID_MARKED_UP, displaytext,
2549 -1); 2581 -1);
2550 g_free (displaytext); 2582 g_free (displaytext);
2551 } 2583 }
2552} 2584}
@@ -2572,30 +2604,142 @@ free_seen_paths (void *cls,
2572 2604
2573 2605
2574/** 2606/**
2575 * Add all updateable entries of the current namespace to the 2607 * User changed the selected namespace. Check if it is valid,
2576 * tree store. 2608 * and if so, update the rest of the dialog accordingly.
2577 * 2609 *
2578 * @param cls the 'GtkTreeStore' to update 2610 * @param combo the namespace selection combo box
2579 * @param name name of the namespace to add 2611 * @param user_data the 'struct MainPublishingDialogContext'
2580 * @param id identity of the namespace to add
2581 */ 2612 */
2582static void 2613void
2583add_namespace_to_ts (GtkTreeStore *ts, 2614GNUNET_GTK_master_publish_dialog_ego_combobox_changed_cb (GtkComboBox *combo,
2584 struct GNUNET_IDENTITY_Ego *ns) 2615 gpointer user_data)
2585{ 2616{
2617 struct MainPublishingDialogContext *ctx = user_data;
2618 GtkTreeIter iter;
2619 GtkTreeStore *ts;
2620 GtkTreeModel *tm;
2621 struct GNUNET_IDENTITY_Ego *ego;
2586 struct UpdateableContext uc; 2622 struct UpdateableContext uc;
2587 2623
2624 ts = GTK_TREE_STORE (gtk_builder_get_object (ctx->builder,
2625 "GNUNET_GTK_update_identifiers_treestore"));
2626 gtk_tree_store_clear (ts);
2627 if (! gtk_combo_box_get_active_iter (combo, &iter))
2628 {
2629 /* entry unselected, etc. */
2630 ctx->ns = NULL;
2631 gtk_widget_set_sensitive (ctx->identifier_entry, FALSE);
2632 gtk_widget_set_sensitive (ctx->updateable_checkbox, FALSE);
2633 gtk_widget_set_sensitive (ctx->update_id_entry, FALSE);
2634 update_selectivity_execute_cancel (ctx);
2635 return;
2636 }
2637 tm = GTK_TREE_MODEL (gtk_builder_get_object (ctx->builder,
2638 "GNUNET_GTK_master_publish_dialog_ego_liststore"));
2639 gtk_tree_model_get (tm, &iter,
2640 EGO_MC_EGO, &ego,
2641 -1);
2642 if (NULL == ego)
2643 {
2644 GNUNET_break (0);
2645 gtk_widget_set_sensitive (ctx->identifier_entry, FALSE);
2646 gtk_widget_set_sensitive (ctx->updateable_checkbox, FALSE);
2647 gtk_widget_set_sensitive (ctx->update_id_entry, FALSE);
2648 update_selectivity_execute_cancel (ctx);
2649 return;
2650 }
2651 ctx->ns = ego;
2588 uc.parent = NULL; 2652 uc.parent = NULL;
2589 uc.ts = ts; 2653 uc.ts = ts;
2590 uc.ns = ns; 2654 uc.ns = ego;
2591 uc.update_called = GNUNET_NO; 2655 uc.update_called = GNUNET_NO;
2592 uc.seen = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO); 2656 uc.seen = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO);
2657
2593 GNUNET_FS_namespace_list_updateable (GNUNET_FS_GTK_get_fs_handle (), 2658 GNUNET_FS_namespace_list_updateable (GNUNET_FS_GTK_get_fs_handle (),
2594 GNUNET_IDENTITY_ego_get_private_key (uc.ns), 2659 GNUNET_IDENTITY_ego_get_private_key (ego),
2595 NULL, 2660 NULL,
2596 &add_updateable_to_ts, &uc); 2661 &add_updateable_to_ts,
2597 GNUNET_CONTAINER_multihashmap_iterate (uc.seen, free_seen_paths, NULL); 2662 &uc);
2663 GNUNET_CONTAINER_multihashmap_iterate (uc.seen, &free_seen_paths, NULL);
2598 GNUNET_CONTAINER_multihashmap_destroy (uc.seen); 2664 GNUNET_CONTAINER_multihashmap_destroy (uc.seen);
2665 gtk_widget_set_sensitive (ctx->identifier_entry, TRUE);
2666 gtk_widget_set_sensitive (ctx->updateable_checkbox, TRUE);
2667 gtk_widget_set_sensitive (ctx->update_id_entry, TRUE);
2668 update_selectivity_execute_cancel (ctx);
2669}
2670
2671
2672/**
2673 * Add all updateable entries of the current namespace to the
2674 * tree store.
2675 *
2676 * @param cls our 'struct MainPublishingDialogContext'
2677 * @param ego identity of the namespace to add
2678 * @param ego_ctx where to store context data
2679 * @param name name of the namespace to add
2680 */
2681static void
2682add_namespace_to_ts (void *cls,
2683 struct GNUNET_IDENTITY_Ego *ego,
2684 void **ego_ctx,
2685 const char *name)
2686{
2687 struct MainPublishingDialogContext *ctx = cls;
2688 GtkListStore *ls;
2689 GtkTreePath *path;
2690 GtkTreeRowReference *rr;
2691 GtkTreeIter iter;
2692 gboolean have_ns;
2693
2694 if (NULL == ego)
2695 return; /* nothing to be done */
2696 ls = GTK_LIST_STORE (gtk_builder_get_object (ctx->builder,
2697 "GNUNET_GTK_master_publish_dialog_ego_liststore"));
2698 rr = *ego_ctx;
2699 if (NULL == rr)
2700 {
2701 /* insert operation */
2702 GNUNET_assert (NULL != name);
2703 gtk_list_store_insert_with_values (ls,
2704 &iter, G_MAXINT,
2705 EGO_MC_NAME, name,
2706 EGO_MC_EGO, ego,
2707 -1);
2708 path = gtk_tree_model_get_path (GTK_TREE_MODEL (ls),
2709 &iter);
2710 rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (ls),
2711 path);
2712 gtk_tree_path_free (path);
2713 *ego_ctx = rr;
2714 }
2715 else if (NULL == name)
2716 {
2717 /* delete operation */
2718 path = gtk_tree_row_reference_get_path (rr);
2719 gtk_tree_row_reference_free (rr);
2720 GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (ls),
2721 &iter, path));
2722 gtk_tree_path_free (path);
2723 gtk_list_store_remove (ls, &iter);
2724 *ego_ctx = NULL;
2725 }
2726 else
2727 {
2728 /* rename operation */
2729 path = gtk_tree_row_reference_get_path (rr);
2730 GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (ls),
2731 &iter, path));
2732 gtk_list_store_set (ls,
2733 &iter, G_MAXINT,
2734 EGO_MC_NAME, name,
2735 -1);
2736 gtk_tree_path_free (path);
2737 }
2738 have_ns = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ls), &iter);
2739 gtk_widget_set_sensitive (ctx->own_checkbox, have_ns);
2740 gtk_widget_set_sensitive (ctx->identifier_entry, have_ns);
2741 gtk_widget_set_sensitive (ctx->updateable_checkbox, have_ns);
2742 gtk_widget_set_sensitive (ctx->update_id_entry, have_ns);
2599} 2743}
2600 2744
2601 2745
@@ -2610,9 +2754,8 @@ GNUNET_GTK_main_menu_file_publish_activate_cb (GtkWidget * dummy,
2610 gpointer user_data) 2754 gpointer user_data)
2611{ 2755{
2612 struct MainPublishingDialogContext *ctx; 2756 struct MainPublishingDialogContext *ctx;
2613/* GtkTreeView *pseudonym_treeview;*/
2614 const struct GNUNET_CONFIGURATION_Handle *cfg; 2757 const struct GNUNET_CONFIGURATION_Handle *cfg;
2615 gboolean have_ns; 2758 GtkWidget *toplevel;
2616 int updateable_enabled; 2759 int updateable_enabled;
2617 int own_enabled; 2760 int own_enabled;
2618 int global_enabled; 2761 int global_enabled;
@@ -2642,7 +2785,7 @@ GNUNET_GTK_main_menu_file_publish_activate_cb (GtkWidget * dummy,
2642 ctx->execute_button = GTK_WIDGET (gtk_builder_get_object 2785 ctx->execute_button = GTK_WIDGET (gtk_builder_get_object
2643 (ctx->builder, "GNUNET_GTK_master_publish_dialog_execute_button")); 2786 (ctx->builder, "GNUNET_GTK_master_publish_dialog_execute_button"));
2644 ctx->cancel_button = GTK_WIDGET (gtk_builder_get_object 2787 ctx->cancel_button = GTK_WIDGET (gtk_builder_get_object
2645 (ctx->builder , "GNUNET_GTK_master_publish_dialog_cancel_button")); 2788 (ctx->builder, "GNUNET_GTK_master_publish_dialog_cancel_button"));
2646 ctx->file_info_treeview = GTK_TREE_VIEW (gtk_builder_get_object 2789 ctx->file_info_treeview = GTK_TREE_VIEW (gtk_builder_get_object
2647 (ctx->builder, "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); 2790 (ctx->builder, "GNUNET_GTK_master_publish_dialog_file_information_tree_view"));
2648 ctx->file_info_selection = gtk_tree_view_get_selection (ctx->file_info_treeview); 2791 ctx->file_info_selection = gtk_tree_view_get_selection (ctx->file_info_treeview);
@@ -2652,20 +2795,18 @@ GNUNET_GTK_main_menu_file_publish_activate_cb (GtkWidget * dummy,
2652 (ctx->builder, "GNUNET_GTK_master_publish_dialog")); 2795 (ctx->builder, "GNUNET_GTK_master_publish_dialog"));
2653 2796
2654 ctx->global_checkbox = GTK_WIDGET (gtk_builder_get_object 2797 ctx->global_checkbox = GTK_WIDGET (gtk_builder_get_object
2655 (ctx->builder , "GNUNET_GTK_master_publish_dialog_global_checkbox")); 2798 (ctx->builder, "GNUNET_GTK_master_publish_dialog_global_checkbox"));
2656 ctx->own_checkbox = GTK_WIDGET (gtk_builder_get_object 2799 ctx->own_checkbox = GTK_WIDGET (gtk_builder_get_object
2657 (ctx->builder , "GNUNET_GTK_master_publish_dialog_own_checkbox")); 2800 (ctx->builder, "GNUNET_GTK_master_publish_dialog_own_checkbox"));
2658 ctx->own_label = GTK_WIDGET (gtk_builder_get_object
2659 (ctx->builder , "GNUNET_GTK_master_publish_dialog_own_label"));
2660 ctx->updateable_checkbox = GTK_WIDGET (gtk_builder_get_object 2801 ctx->updateable_checkbox = GTK_WIDGET (gtk_builder_get_object
2661 (ctx->builder , "GNUNET_GTK_master_publish_dialog_updateable_checkbox")); 2802 (ctx->builder, "GNUNET_GTK_master_publish_dialog_updateable_checkbox"));
2662 ctx->update_id_entry = GTK_WIDGET (gtk_builder_get_object 2803 ctx->update_id_entry = GTK_WIDGET (gtk_builder_get_object
2663 (ctx->builder , "GNUNET_GTK_master_publish_dialog_update_id_entry")); 2804 (ctx->builder, "GNUNET_GTK_master_publish_dialog_update_id_entry"));
2664 2805
2665 ctx->own_vbox = GTK_WIDGET (gtk_builder_get_object 2806 ctx->own_vbox = GTK_WIDGET (gtk_builder_get_object
2666 (ctx->builder , "GNUNET_GTK_master_publish_dialog_own_vbox")); 2807 (ctx->builder, "GNUNET_GTK_master_publish_dialog_own_vbox"));
2667 ctx->update_id_hbox = GTK_WIDGET (gtk_builder_get_object 2808 ctx->update_id_hbox = GTK_WIDGET (gtk_builder_get_object
2668 (ctx->builder , "GNUNET_GTK_master_publish_dialog_update_id_hbox")); 2809 (ctx->builder, "GNUNET_GTK_master_publish_dialog_update_id_hbox"));
2669 2810
2670 ctx->identifiers_expander = GTK_WIDGET (gtk_builder_get_object (ctx->builder, "GNUNET_GTK_master_publish_dialog_previous_identifiers_expander")); 2811 ctx->identifiers_expander = GTK_WIDGET (gtk_builder_get_object (ctx->builder, "GNUNET_GTK_master_publish_dialog_previous_identifiers_expander"));
2671 ctx->vpaned = GTK_WIDGET (gtk_builder_get_object (ctx->builder, "GNUNET_GTK_master_publish_dialog_vpaned")); 2812 ctx->vpaned = GTK_WIDGET (gtk_builder_get_object (ctx->builder, "GNUNET_GTK_master_publish_dialog_vpaned"));
@@ -2687,50 +2828,10 @@ GNUNET_GTK_main_menu_file_publish_activate_cb (GtkWidget * dummy,
2687 G_CALLBACK (identifiers_selection_changed_cb), ctx); 2828 G_CALLBACK (identifiers_selection_changed_cb), ctx);
2688 2829
2689 cfg = GNUNET_FS_GTK_get_configuration (); 2830 cfg = GNUNET_FS_GTK_get_configuration ();
2690#if FIXME_MIGRATE_TO_IDENTITY_SERVICE 2831 ctx->identity = GNUNET_IDENTITY_connect (cfg,
2691 if (GNUNET_OK != 2832 &add_namespace_to_ts,
2692 GNUNET_CONFIGURATION_get_value_string (cfg, 2833 ctx);
2693 "gnunet-fs-gtk",
2694 "DEFAULT_NAMESPACE",
2695 &ctx->ns_name))
2696 ctx->ns_name = NULL;
2697 else
2698 {
2699 ctx->ns = GNUNET_FS_namespace_open_existing (GNUNET_FS_GTK_get_fs_handle (),
2700 ctx->ns_name);
2701 if (NULL == ctx->ns)
2702 GNUNET_free (ctx->ns_name);
2703 }
2704#endif
2705 have_ns = (NULL != ctx->ns);
2706 2834
2707 gtk_widget_set_sensitive (ctx->own_checkbox, have_ns);
2708 gtk_widget_set_sensitive (ctx->identifier_entry, have_ns);
2709 gtk_widget_set_sensitive (ctx->updateable_checkbox, have_ns);
2710 gtk_widget_set_sensitive (ctx->update_id_entry, have_ns);
2711 if (ctx->ns)
2712 {
2713 gtk_label_set_text (GTK_LABEL (ctx->own_label), ctx->ns_name);
2714 gtk_widget_set_tooltip_text (ctx->own_label, _(
2715 "This is the label of your namespace that will be used for "
2716 "publication, if you enable that option.\n"
2717 "This label will not be part of the publication.\n"
2718 "If you don't like this label, use Namespace Organizer to change it."
2719 ));
2720 add_namespace_to_ts (GTK_TREE_STORE (ctx->identifiers_treemodel), ctx->ns);
2721 gtk_tree_view_expand_all (ctx->identifiers_treeview);
2722 }
2723 else
2724 {
2725 gtk_label_set_text (GTK_LABEL (ctx->own_label),
2726 _("<no namespace is selected>"));
2727 gtk_widget_set_tooltip_text (ctx->own_label, _(
2728 "Namespace publication is unavailable, no namespace is selected.\n"
2729 "Try to close this dialog, open Namespace Organizer dialog, and "
2730 "select a namespace from a list of namespaces you own.\n"
2731 "You may need to create one, if you don't have any."
2732 ));
2733 }
2734 2835
2735 updateable_enabled = GNUNET_CONFIGURATION_get_value_yesno (cfg, 2836 updateable_enabled = GNUNET_CONFIGURATION_get_value_yesno (cfg,
2736 "gnunet-fs-gtk", "MAKE_UPDATEABLE_PUBLICATIONS_BY_DEFAULT"); 2837 "gnunet-fs-gtk", "MAKE_UPDATEABLE_PUBLICATIONS_BY_DEFAULT");
@@ -2756,6 +2857,10 @@ GNUNET_GTK_main_menu_file_publish_activate_cb (GtkWidget * dummy,
2756 GNUNET_YES == global_enabled); 2857 GNUNET_YES == global_enabled);
2757 2858
2758 /* show dialog */ 2859 /* show dialog */
2860 toplevel = gtk_widget_get_toplevel (dummy);
2861 if (GTK_IS_WINDOW (toplevel))
2862 gtk_window_set_transient_for (GTK_WINDOW (ctx->master_pubdialog),
2863 GTK_WINDOW (toplevel));
2759 gtk_window_present (GTK_WINDOW (ctx->master_pubdialog)); 2864 gtk_window_present (GTK_WINDOW (ctx->master_pubdialog));
2760} 2865}
2761 2866