From 32d05eb8d248a61258aa8e506b8a512fc2d54006 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 28 Jun 2018 19:00:47 +0200 Subject: kill gnunet-identity-gtk, does not do anything more useful than gnunet-namestore-gtk --- configure.ac | 1 - src/Makefile.am | 2 +- src/identity/.gitignore | 1 - src/identity/Makefile.am | 24 - src/identity/gnunet-identity-gtk.c | 550 --------------------- src/identity/gnunet-identity-gtk.h | 40 -- src/identity/gnunet-identity-gtk_about.c | 41 -- src/identity/gnunet-identity-gtk_advertise.c | 688 --------------------------- src/identity/gnunet-identity-gtk_advertise.h | 51 -- 9 files changed, 1 insertion(+), 1397 deletions(-) delete mode 100644 src/identity/.gitignore delete mode 100644 src/identity/Makefile.am delete mode 100644 src/identity/gnunet-identity-gtk.c delete mode 100644 src/identity/gnunet-identity-gtk.h delete mode 100644 src/identity/gnunet-identity-gtk_about.c delete mode 100644 src/identity/gnunet-identity-gtk_advertise.c delete mode 100644 src/identity/gnunet-identity-gtk_advertise.h diff --git a/configure.ac b/configure.ac index 8379d2a7..9795ac06 100644 --- a/configure.ac +++ b/configure.ac @@ -541,7 +541,6 @@ src/include/Makefile src/lib/Makefile src/fs/Makefile src/fs/gnunet-fs-gtk.conf -src/identity/Makefile src/peerinfo/Makefile src/namestore/Makefile src/setup/Makefile diff --git a/src/Makefile.am b/src/Makefile.am index 4fefc153..fea6f370 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,2 +1,2 @@ # This Makefile.am is in the public domain -SUBDIRS = . include lib $(GNUNET_FS_APP) $(GNUNET_SETUP_APP) $(GNUNET_PEERINFO_APP) $(GNUNET_CONVERSATION_APP) statistics identity namestore +SUBDIRS = . include lib $(GNUNET_FS_APP) $(GNUNET_SETUP_APP) $(GNUNET_PEERINFO_APP) $(GNUNET_CONVERSATION_APP) statistics namestore diff --git a/src/identity/.gitignore b/src/identity/.gitignore deleted file mode 100644 index 7c1303af..00000000 --- a/src/identity/.gitignore +++ /dev/null @@ -1 +0,0 @@ -gnunet-identity-gtk diff --git a/src/identity/Makefile.am b/src/identity/Makefile.am deleted file mode 100644 index 33f9a62c..00000000 --- a/src/identity/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -# This Makefile.am is in the public domain -SUBDIRS = . - -AM_CPPFLAGS = \ - -I$(top_srcdir)/ \ - -I$(top_srcdir)/src/include \ - @GTK_CFLAGS@ \ - @GNUNET_CFLAGS@ \ - @GLADE_CFLAGS@ - -bin_PROGRAMS = gnunet-identity-gtk - -gnunet_identity_gtk_SOURCES = \ - gnunet-identity-gtk.c gnunet-identity-gtk.h \ - gnunet-identity-gtk_about.c \ - gnunet-identity-gtk_advertise.c gnunet-identity-gtk_advertise.h -gnunet_identity_gtk_LDADD = \ - $(top_builddir)/src/lib/libgnunetgtk.la \ - @GTK_LIBS@ \ - @GLADE_LIBS@ @GNUNET_LIBS@ \ - -lgnunetutil -lgnunetidentity -lgnunetfs -lextractor \ - $(INTLLIBS) -gnunet_identity_gtk_LDFLAGS = \ - -export-dynamic diff --git a/src/identity/gnunet-identity-gtk.c b/src/identity/gnunet-identity-gtk.c deleted file mode 100644 index 11800fce..00000000 --- a/src/identity/gnunet-identity-gtk.c +++ /dev/null @@ -1,550 +0,0 @@ -/* - This file is part of GNUnet. - Copyright (C) 2010-2013 GNUnet e.V. - - 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 3, 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., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -/** - * @file src/identity/gnunet-identity-gtk.c - * @brief Main function of gnunet-identity-gtk - * @author Christian Grothoff - */ -#include "gnunet_gtk.h" -#include -#include "gnunet-identity-gtk_advertise.h" - - -/** - * Columns in the identity model. - */ -enum IDENTITY_ModelColumns - { - /** - * A gchararray - */ - IDENTITY_MC_NAME = 0, - - /** - * A gchararray - */ - IDENTITY_MC_IDENTIFIER = 1, - - /** - * A 'struct GNUNET_IDENTIFIER_Ego' - */ - IDENTITY_MC_EGO = 2 - - }; - - -/** - * Handle to our main loop. - */ -static struct GNUNET_GTK_MainLoop *ml; - -/** - * Handle to IDENTITY service. - */ -static struct GNUNET_IDENTITY_Handle *identity; - -/** - * Main window list store. - */ -static GtkListStore *ls; - - -/** - * We need to track active operations with the identity service. - */ -struct OperationContext -{ - - /** - * Kept in a DLL. - */ - struct OperationContext *next; - - /** - * Kept in a DLL. - */ - struct OperationContext *prev; - - /** - * Operation handle with the identity service. - */ - struct GNUNET_IDENTITY_Operation *op; - -}; - - -/** - * Head of operations. - */ -static struct OperationContext *oc_head; - -/** - * Tail of operations. - */ -static struct OperationContext *oc_tail; - - -/** - * Get our configuration. - * - * @return configuration handle - */ -const struct GNUNET_CONFIGURATION_Handle * -GIG_get_configuration () -{ - return GNUNET_GTK_main_loop_get_configuration (ml); -} - - -/** - * Get an object from the main window. - * - * @param name name of the object - * @return NULL on error - */ -static GObject * -get_object (const char *name) -{ - return GNUNET_GTK_main_loop_get_object (ml, name); -} - - -/** - * Identity operation was finished, clean up. - * - * @param cls the 'struct OperationContext' - * @param emsg error message (NULL on success) - */ -static void -operation_finished (void *cls, - const char *emsg) -{ - struct OperationContext *oc = cls; - - GNUNET_CONTAINER_DLL_remove (oc_head, - oc_tail, - oc); - gtk_widget_set_sensitive (GTK_WIDGET (get_object ("GNUNET_GTK_identity_treeview")), - TRUE); - GNUNET_free (oc); -} - - -/** - * Context for the advertise popup menu. - */ -struct AdvertisePopupContext -{ - /** - * Ego to advertise. - */ - struct GNUNET_IDENTITY_Ego *ego; - -}; - - -/** - * "Advertise" was selected in the current context menu. - * - * @param item the 'advertise' menu item - * @param user_data the 'struct AdvertisePopupContext' of the menu - */ -static void -advertise_ctx_menu (GtkMenuItem *item, - gpointer user_data) -{ - struct AdvertisePopupContext *apc = user_data; - const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv; - - priv = GNUNET_IDENTITY_ego_get_private_key (apc->ego); - GIG_advertise_dialog_start_ (priv); -} - - -/** - * An item was selected from the context menu; destroy the menu shell. - * - * @param menushell menu to destroy - * @param user_data the 'struct AdvertisePopupContext' of the menu - */ -static void -advertise_popup_selection_done (GtkMenuShell *menushell, - gpointer user_data) -{ - struct AdvertisePopupContext *apc = user_data; - - gtk_widget_destroy (GTK_WIDGET (menushell)); - GNUNET_free (apc); -} - - -/** - * User clicked in the treeview widget. Check for right button - * to possibly launch advertise window. - * - * @param widget the treeview widget - * @param event the event, we only care about button events - * @param user_data unused - * @return FALSE if no menu could be popped up, - * TRUE if there is now a pop-up menu - */ -gboolean -GNUNET_GTK_identity_treeview_button_press_event_cb (GtkWidget *widget, - GdkEvent *event, - gpointer user_data) -{ - GtkTreeView *tv = GTK_TREE_VIEW (widget); - GdkEventButton *event_button = (GdkEventButton *) event; - GtkTreeModel *tm; - GtkTreePath *path; - GtkTreeIter iter; - GtkMenu *menu; - GtkWidget *child; - struct AdvertisePopupContext *apc; - struct GNUNET_IDENTITY_Ego *ego; - - if ( (GDK_BUTTON_PRESS != event->type) || - (3 != event_button->button) ) - return FALSE; - if (! gtk_tree_view_get_path_at_pos (tv, - event_button->x, event_button->y, - &path, NULL, NULL, NULL)) - return FALSE; /* click outside of area with values, ignore */ - tm = gtk_tree_view_get_model (tv); - if (! gtk_tree_model_get_iter (tm, &iter, path)) - { - gtk_tree_path_free (path); - return FALSE; /* not sure how we got a path but no iter... */ - } - gtk_tree_path_free (path); - gtk_tree_model_get (GTK_TREE_MODEL (ls), &iter, - IDENTITY_MC_EGO, &ego, - -1); - if (NULL == ego) - return FALSE; - apc = GNUNET_new (struct AdvertisePopupContext); - apc->ego = ego; - menu = GTK_MENU (gtk_menu_new ()); - child = gtk_menu_item_new_with_label (_("_Advertise")); - g_signal_connect (child, "activate", - G_CALLBACK (advertise_ctx_menu), apc); - gtk_label_set_use_underline (GTK_LABEL - (gtk_bin_get_child (GTK_BIN (child))), - TRUE); - gtk_widget_show (child); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), child); - g_signal_connect (menu, "selection-done", - G_CALLBACK (advertise_popup_selection_done), apc); - gtk_menu_popup_at_pointer (menu, - event); - return FALSE; -} - - -/** - * User pushed a key (possibly DEL) in the treeview widget. - * Delete the selected entry if the key was DEL. - * - * @param widget the entry widget - * @param event the key stroke - * @param user_data the main window context - * @return FALSE if this was not ENTER, TRUE if it was - */ -gboolean -GNUNET_GTK_identity_treeview_key_press_event_cb (GtkWidget * widget, - GdkEventKey * event, - gpointer user_data) -{ - gchar *old; - struct OperationContext *oc; - GtkTreeSelection *sel; - GtkTreeIter iter; - - if (GDK_KEY_Delete != event->keyval) - return FALSE; - sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (get_object ("GNUNET_GTK_identity_treeview"))); - if (! gtk_tree_selection_get_selected (sel, NULL, &iter)) - return FALSE; - gtk_tree_model_get (GTK_TREE_MODEL (ls), - &iter, - IDENTITY_MC_NAME, &old, - -1); - oc = GNUNET_new (struct OperationContext); - GNUNET_CONTAINER_DLL_insert (oc_head, - oc_tail, - oc); - oc->op = GNUNET_IDENTITY_delete (identity, - old, - &operation_finished, - oc); - return TRUE; -} - - -/** - * The user edited one of the names of the egos. Change it - * in the IDENTITY service. - * - * @param renderer renderer where the change happened - * @param path location in the model where the change happened - * @param new_text updated text - * @param user_data internal context (not used) - */ -void -GNUNET_GTK_namespace_organizer_namespaces_treeview_column_name_text_edited_cb -(GtkCellRendererText *renderer, - gchar *path, - gchar *new_text, - gpointer user_data) -{ - GtkTreePath *treepath; - GtkTreeIter iter; - struct GNUNET_IDENTITY_Ego *ego; - gchar *old; - struct OperationContext *oc; - - treepath = gtk_tree_path_new_from_string (path); - if (! gtk_tree_model_get_iter (GTK_TREE_MODEL (ls), - &iter, - treepath)) - { - GNUNET_break (0); - gtk_tree_path_free (treepath); - return; - } - gtk_tree_path_free (treepath); - gtk_tree_model_get (GTK_TREE_MODEL (ls), - &iter, - IDENTITY_MC_NAME, &old, - IDENTITY_MC_EGO, &ego, - -1); - gtk_widget_set_sensitive (GTK_WIDGET (get_object ("GNUNET_GTK_identity_treeview")), - FALSE); - oc = GNUNET_new (struct OperationContext); - GNUNET_CONTAINER_DLL_insert (oc_head, - oc_tail, - oc); - if (NULL == ego) - { - /* create operation */ - oc->op = GNUNET_IDENTITY_create (identity, - new_text, - &operation_finished, - oc); - } - else if (0 != strlen (new_text)) - { - /* rename operation */ - oc->op = GNUNET_IDENTITY_rename (identity, - old, new_text, - &operation_finished, - oc); - } - else - { - /* delete operation */ - oc->op = GNUNET_IDENTITY_delete (identity, - old, - &operation_finished, - oc); - } -} - - -/** - * Task run on shutdown. - * - * @param cls unused - */ -static void -shutdown_task (void *cls) -{ - struct OperationContext *oc; - - GIG_advertise_shutdown_ (); - while (NULL != (oc = oc_head)) - { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("Operation not completed due to shutdown\n")); - GNUNET_IDENTITY_cancel (oc->op); - GNUNET_CONTAINER_DLL_remove (oc_head, - oc_tail, - oc); - GNUNET_free (oc); - } - if (NULL != identity) - { - GNUNET_IDENTITY_disconnect (identity); - identity = NULL; - } - GNUNET_GTK_main_loop_quit (ml); - ml = NULL; -} - - -/** - * Callback invoked if the application is supposed to exit. - * - * @param object - * @param user_data unused - */ -void -GNUNET_GTK_identity_quit_cb (GObject * object, gpointer user_data) -{ - GNUNET_SCHEDULER_shutdown (); -} - - -/** - * Add all updateable entries of the current namespace to the - * tree store. - * - * @param cls our 'struct MainPublishingDialogContext' - * @param ego identity of the namespace to add - * @param ego_ctx where to store context data - * @param name name of the namespace to add - */ -static void -add_ego (void *cls, - struct GNUNET_IDENTITY_Ego *ego, - void **ego_ctx, - const char *name) -{ - GtkTreePath *path; - GtkTreeRowReference *rr; - GtkTreeIter iter; - char *id; - struct GNUNET_CRYPTO_EcdsaPublicKey pub; - - if (NULL == ego) - return; /* nothing to be done */ - rr = *ego_ctx; - if (NULL == rr) - { - /* insert operation */ - GNUNET_assert (NULL != name); - GNUNET_IDENTITY_ego_get_public_key (ego, &pub); - id = GNUNET_CRYPTO_ecdsa_public_key_to_string (&pub); - gtk_list_store_insert_with_values (ls, - &iter, G_MAXINT, - IDENTITY_MC_NAME, name, - IDENTITY_MC_IDENTIFIER, id, - IDENTITY_MC_EGO, ego, - -1); - GNUNET_free (id); - path = gtk_tree_model_get_path (GTK_TREE_MODEL (ls), - &iter); - rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (ls), - path); - gtk_tree_path_free (path); - *ego_ctx = rr; - } - else if (NULL == name) - { - /* delete operation */ - path = gtk_tree_row_reference_get_path (rr); - gtk_tree_row_reference_free (rr); - GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (ls), - &iter, path)); - gtk_tree_path_free (path); - gtk_list_store_remove (ls, &iter); - *ego_ctx = NULL; - } - else - { - /* rename operation */ - path = gtk_tree_row_reference_get_path (rr); - GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (ls), - &iter, path)); - gtk_list_store_set (ls, - &iter, - IDENTITY_MC_NAME, name, - -1); - gtk_tree_path_free (path); - } -} - - -/** - * Actual main function run right after GNUnet's scheduler - * is initialized. Initializes up GTK and Glade. - * - * @param cls NULL - */ -static void -run (void *cls) -{ - GtkWidget *main_window; - GtkTreeIter iter; - - ml = cls; - if (GNUNET_OK != GNUNET_GTK_main_loop_build_window (ml, NULL)) - return; - GNUNET_GTK_set_icon_search_path (); - GNUNET_GTK_setup_nls (); - /* setup main window */ - main_window = GTK_WIDGET (get_object ("GNUNET_GTK_identity_window")); - main_window = GNUNET_GTK_plug_me ("GNUNET_IDENTITY_GTK_PLUG", - main_window); - ls = GTK_LIST_STORE (get_object ("GNUNET_GTK_identity_liststore")); - GNUNET_assert (NULL != ls); - gtk_list_store_insert_with_values (ls, - &iter, G_MAXINT, - IDENTITY_MC_NAME, "", - -1); - - gtk_window_maximize (GTK_WINDOW (main_window)); - /* make GUI visible */ - gtk_widget_show (main_window); - gtk_window_present (GTK_WINDOW (main_window)); - identity = GNUNET_IDENTITY_connect (GIG_get_configuration (), - &add_ego, - NULL); - GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); -} - - -/** - * Main function of gnunet-identity-gtk. - * - * @param argc number of arguments - * @param argv arguments - * @return 0 on success - */ -int -main (int argc, char *const *argv) -{ - static struct GNUNET_GETOPT_CommandLineOption options[] = { - GNUNET_GETOPT_OPTION_END - }; - - if (GNUNET_OK != - GNUNET_GTK_main_loop_start ("gnunet-identity-gtk", - "GTK GUI for managing egos", argc, - argv, options, - "gnunet_identity_gtk_main_window.glade", - &run)) - return 1; - return 0; -} - - -/* end of gnunet-identity-gtk.c */ diff --git a/src/identity/gnunet-identity-gtk.h b/src/identity/gnunet-identity-gtk.h deleted file mode 100644 index 8e7bdbef..00000000 --- a/src/identity/gnunet-identity-gtk.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - This file is part of GNUnet - Copyright (C) 2013 GNUnet e.V. - - 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 3, 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., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -/** - * @file src/identity/gnunet-identity-gtk.h - * @author Christian Grothoff - */ -#include - - -#ifndef GNUNET_IDENTITY_GTK_H -#define GNUNET_IDENTITY_GTK_H - -/** - * Get our configuration. - * - * @return configuration handle - */ -const struct GNUNET_CONFIGURATION_Handle * -GIG_get_configuration (void); - - -#endif diff --git a/src/identity/gnunet-identity-gtk_about.c b/src/identity/gnunet-identity-gtk_about.c deleted file mode 100644 index a6c079b3..00000000 --- a/src/identity/gnunet-identity-gtk_about.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - This file is part of GNUnet - Copyright (C) 2005-2013 GNUnet e.V. - - 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 3, 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., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ -/** - * @file src/identity/gnunet-identity-gtk_about.c - * @author Christian Grothoff - * @author Igor Wronsky - * - * This file contains the about dialog. - */ -#include "gnunet_gtk.h" - - -/** - * This displays an about window - */ -void -GNUNET_GTK_identity_about_imagemenuitem_activate_cb (GtkWidget * dummy, - gpointer data) -{ - GNUNET_GTK_display_about ("gnunet_identity_gtk_about_window.glade"); -} - - -/* end of gnunet-peerinfo-gtk_about.c */ diff --git a/src/identity/gnunet-identity-gtk_advertise.c b/src/identity/gnunet-identity-gtk_advertise.c deleted file mode 100644 index d5a8eecf..00000000 --- a/src/identity/gnunet-identity-gtk_advertise.c +++ /dev/null @@ -1,688 +0,0 @@ -/* - This file is part of GNUnet - Copyright (C) 2005-2013 GNUnet e.V. - - 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 3, 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., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -/** - * @file src/identity/gnunet-identity-gtk_advertise.c - * @author LRN - * @author Christian Grothoff - */ -#include "gnunet-identity-gtk_advertise.h" -#include "gnunet-identity-gtk.h" -#include -#if HAVE_EXTRACTOR_H -#include -#endif - -#define NEW_KEYWORD_TEXT "" - - -/** - * Types of metadata we offer for namespaces. - */ -static gint types[] = -{ - EXTRACTOR_METATYPE_TITLE, - EXTRACTOR_METATYPE_KEYWORDS, - EXTRACTOR_METATYPE_SUBJECT, - EXTRACTOR_METATYPE_DESCRIPTION, - EXTRACTOR_METATYPE_COMMENT, - EXTRACTOR_METATYPE_URI, -#if HAVE_EXTRACTOR_H - EXTRACTOR_METATYPE_COPYRIGHT, - EXTRACTOR_METATYPE_CREATOR, - EXTRACTOR_METATYPE_CREATION_DATE, -#endif - EXTRACTOR_METATYPE_RESERVED -}; - - -/** - * Columns in the metadata list store. - */ -enum METADATA_ModelColumns -{ - - /** - * A guint - */ - METADATA_MC_TYPE_AS_ENUM = 0, - - /** - * A gchararray - */ - METADATA_MC_TYPE_AS_STRING = 1, - - /** - * A gchararray - */ - METADATA_MC_VALUE = 2 - -}; - - -/** - * Columns in the keyword list tree store. - */ -enum KEYWORDS_ModelColumns -{ - - /** - * A gchararray - */ - KEYWORDS_MC_KEYWORD = 0 - -}; - - -/** - * Columns in the meta types list tree store. - */ -enum METATYPES_ModelColumns -{ - - /** - * A gchararray - */ - METATYPES_MC_TYPE_AS_STRING = 0, - - /** - * A guint - */ - METATYPES_MC_TYPE_AS_ENUM = 1 - -}; - - -/** - * Context for advertisement operations. - */ -struct AdvertiseContext -{ - /** - * Builder for accessing objects in the dialog. - */ - GtkBuilder *builder; - - /** - * Private key of the namespace we will be advertising. - */ - struct GNUNET_CRYPTO_EcdsaPrivateKey priv; - - /** - * Main dialog object. - */ - GtkWidget *dialog; - - /** - * List of keywords to advertise under. - */ - GtkListStore *keywords; - - /** - * Metadata to include in the advertisement. - */ - GtkListStore *metadata; - - /** - * Model with the meta types. - */ - GtkListStore *meta_types; - - /** - * Number of keywords in the view. - */ - unsigned int num_keywords; - -}; - - -/** - * Context for the publishing operation. - */ -struct PublishContext -{ - - /** - * Kept in a DLL. - */ - struct PublishContext *next; - - /** - * Kept in a DLL. - */ - struct PublishContext *prev; - - /** - * Handle to FS subsystem. - */ - struct GNUNET_FS_Handle *fs; - - /** - * Handle to the publish operation. - */ - struct GNUNET_FS_PublishKskContext *pub; - -}; - - -/** - * Kept in a DLL. - */ -static struct PublishContext *pc_head; - -/** - * Kept in a DLL. - */ -static struct PublishContext *pc_tail; - - -/** - * Shutdown advertisement subsystem, this process is terminating. - */ -void -GIG_advertise_shutdown_ () -{ - struct PublishContext *pc; - - while (NULL != (pc = pc_head)) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Aborting advertising operation due to shutdown.\n")); - GNUNET_CONTAINER_DLL_remove (pc_head, - pc_tail, - pc); - GNUNET_FS_publish_ksk_cancel (pc->pub); - GNUNET_FS_stop (pc->fs); - GNUNET_free (pc); - } -} - - -/** - * Function called once we published the advertisement. - * - * @param cls closure with the `struct PublishContext` - * @param uri URI under which the block is now available, NULL on error - * @param emsg error message, NULL on success - */ -static void -publish_continuation (void *cls, - const struct GNUNET_FS_Uri *uri, - const char *emsg) -{ - struct PublishContext *pc = cls; - - pc->pub = NULL; - if (NULL == uri) - { - GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Failed to advertise ego: %s\n"), - emsg); - /* FIXME: might want to output to GUI... */ - } - GNUNET_FS_stop (pc->fs); - GNUNET_CONTAINER_DLL_remove (pc_head, - pc_tail, - pc); - GNUNET_free (pc); -} - - -/** - * Notification of FS to a client about the progress of an - * operation. Callbacks of this type will be used for uploads, - * downloads and searches. Some of the arguments depend a bit - * in their meaning on the context in which the callback is used. - * - * @param cls closure - * @param info details about the event, specifying the event type - * and various bits about the event - * @return client-context (for the next progress call - * for this operation; should be set to NULL for - * SUSPEND and STOPPED events). The value returned - * will be passed to future callbacks in the respective - * field in the `struct GNUNET_FS_ProgressInfo`. - */ -static void * -progress_cb (void *cls, - const struct GNUNET_FS_ProgressInfo *info) -{ - return NULL; -} - - -/** - * The user terminated the dialog. Perform the appropriate action. - * - * @param dialog the advertisement dialog - * @param response_id action selected by the user - * @param user_data our 'struct AdvertiseContext' (to be cleaned up) - */ -void -GNUNET_GTK_identity_advertise_dialog_response_cb (GtkDialog *dialog, - gint response_id, - gpointer user_data) -{ - struct AdvertiseContext *ac = user_data; - struct GNUNET_FS_Uri *ksk_uri; - struct GNUNET_FS_Uri *uri; - gchar *keyword; - struct GNUNET_CONTAINER_MetaData *meta; - guint ntype; - gchar *value; - GtkTreeIter iter; - struct GNUNET_FS_BlockOptions bo; - struct GNUNET_CRYPTO_EcdsaPublicKey pk; - struct PublishContext *pc; - guint anonymity; - const char *id; - - if (GTK_RESPONSE_OK != response_id) - goto cleanup; - ksk_uri = NULL; - if (! gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ac->keywords), &iter)) - { - GNUNET_break (0); - goto cleanup; - } - do - { - gtk_tree_model_get (GTK_TREE_MODEL (ac->keywords), &iter, - KEYWORDS_MC_KEYWORD, &keyword, - -1); - if (NULL == ksk_uri) - ksk_uri = GNUNET_FS_uri_ksk_create_from_args (1, (const char **) &keyword); - else - GNUNET_FS_uri_ksk_add_keyword (ksk_uri, keyword, GNUNET_NO); - g_free (keyword); - } - while (gtk_tree_model_iter_next (GTK_TREE_MODEL (ac->keywords), &iter)); - - meta = GNUNET_CONTAINER_meta_data_create (); - if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (ac->metadata), - &iter)) - { - do - { - gtk_tree_model_get (GTK_TREE_MODEL (ac->metadata), &iter, - METADATA_MC_TYPE_AS_ENUM, &ntype, - METADATA_MC_VALUE, &value, - -1); - if (ntype > 0) - { - GNUNET_CONTAINER_meta_data_insert (meta, "", - ntype, - EXTRACTOR_METAFORMAT_UTF8, - "text/plain", value, - strlen (value) + 1); - } - g_free (value); - } - while (gtk_tree_model_iter_next (GTK_TREE_MODEL (ac->metadata), &iter)); - } - - bo.expiration_time = GNUNET_GTK_get_expiration_time - (GTK_SPIN_BUTTON - (gtk_builder_get_object - (ac->builder, - "GNUNET_GTK_identity_advertise_expiration_year_spin_button"))); - anonymity = 1; - GNUNET_break (GNUNET_GTK_get_selected_anonymity_level (ac->builder, - "GNUNET_GTK_identity_advertise_anonymity_combobox", - &anonymity)); - bo.anonymity_level = anonymity; - bo.content_priority - = (unsigned int) gtk_spin_button_get_value - (GTK_SPIN_BUTTON - (gtk_builder_get_object - (ac->builder, - "GNUNET_GTK_identity_advertise_priority_spin_button"))); - bo.replication_level - = (unsigned int) gtk_spin_button_get_value - (GTK_SPIN_BUTTON - (gtk_builder_get_object - (ac->builder, - "GNUNET_GTK_identity_advertise_replication_spin_button"))); - GNUNET_CRYPTO_ecdsa_key_get_public (&ac->priv, - &pk); - id = gtk_entry_get_text - (GTK_ENTRY - (gtk_builder_get_object - (ac->builder, - "GNUNET_GTK_identity_advertise_root_entry"))); - uri = GNUNET_FS_uri_sks_create (&pk, id); - - pc = GNUNET_new (struct PublishContext); - pc->fs = GNUNET_FS_start (GIG_get_configuration (), - "gnunet-identity-gtk", - &progress_cb, pc, - GNUNET_FS_FLAGS_NONE, - GNUNET_FS_OPTIONS_END); - pc->pub = GNUNET_FS_publish_ksk (pc->fs, - ksk_uri, - meta, - uri, - &bo, - GNUNET_FS_PUBLISH_OPTION_NONE, - &publish_continuation, pc); - GNUNET_CONTAINER_DLL_insert (pc_head, - pc_tail, - pc); - GNUNET_FS_uri_destroy (uri); - GNUNET_CONTAINER_meta_data_destroy (meta); - cleanup: - gtk_widget_destroy (ac->dialog); - g_object_unref (G_OBJECT (ac->builder)); - GNUNET_free (ac); -} - - -/** - * User edited keywords in the keyword tree view. Update - * the model accordingly. - * - * @param renderer the object that created the signal - * @param path the path identifying the edited cell - * @param new_text the new text - * @param user_data the 'struct AdvertiseContext' - */ -void -GNUNET_GTK_identity_advertise_keywords_text_edited_cb (GtkCellRendererText *renderer, - gchar *path, - gchar *new_text, - gpointer user_data) -{ - struct AdvertiseContext *ac = user_data; - GtkTreePath *tree_path; - GtkTreeIter iter; - char *old_text; - - tree_path = gtk_tree_path_new_from_string (path); - if (NULL == tree_path) - { - GNUNET_break (0); - return; - } - if (! gtk_tree_model_get_iter (GTK_TREE_MODEL (ac->keywords), - &iter, tree_path)) - { - GNUNET_break (0); - gtk_tree_path_free (tree_path); - return; - } - gtk_tree_path_free (tree_path); - gtk_tree_model_get (GTK_TREE_MODEL (ac->keywords), &iter, - KEYWORDS_MC_KEYWORD, &old_text, - -1); - if (0 == strcmp (NEW_KEYWORD_TEXT, old_text)) - { - if ( (NULL != new_text) && - (0 != strlen (new_text)) ) - { - gtk_list_store_insert_with_values (ac->keywords, &iter, -1, - KEYWORDS_MC_KEYWORD, new_text, - -1); - ac->num_keywords++; - } - } - else - { - if ( (NULL != new_text) && - (0 != strlen (new_text)) ) - { - gtk_list_store_set (ac->keywords, &iter, - KEYWORDS_MC_KEYWORD, new_text, - -1); - } - else - { - gtk_list_store_remove (ac->keywords, &iter); - ac->num_keywords--; - } - } - g_free (old_text); - gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object - (ac->builder, - "GNUNET_GTK_identity_advertise_ok_button")), - 0 != ac->num_keywords); -} - - -/** - * User pushed a key in the metadata tree view. Check if it was - * "DEL" and if so, remove the selected values. - * - * @param widget widget creating the signal - * @param event the event to process - * @param user_data the 'struct AdvertiseContext' - * @return TRUE if we handled the event, FALSE if not - */ -gboolean -GNUNET_GTK_identity_advertise_metadata_treeview_key_press_event_cb (GtkWidget *widget, - GdkEventKey *event, - gpointer user_data) -{ - struct AdvertiseContext *ac = user_data; - GtkTreeSelection *sel; - GtkTreeModel *model; - GtkTreeIter iter; - - if (event->keyval != GDK_KEY_Delete) - return FALSE; - sel = gtk_tree_view_get_selection (GTK_TREE_VIEW - (gtk_builder_get_object - (ac->builder, - "GNUNET_GTK_identity_advertise_metadata_treeview"))); - if (! gtk_tree_selection_get_selected (sel, - &model, - &iter)) - { - gdk_beep (); - return TRUE; - } - gtk_list_store_remove (ac->metadata, - &iter); - return TRUE; -} - - -/** - * User edited metadata value in the tree view. Update the model. - * - * @param renderer the object that created the signal - * @param path the path identifying the edited cell - * @param new_text the new text, if empty, remove the line - * @param user_data the 'struct AdvertiseContext' - */ -void -GNUNET_GTK_identity_advertise_metadata_value_text_edited_cb (GtkCellRendererText *renderer, - gchar *path, - gchar *new_text, - gpointer user_data) -{ - struct AdvertiseContext *ac = user_data; - GtkTreePath *tree_path; - GtkTreeIter iter; - - tree_path = gtk_tree_path_new_from_string (path); - if (NULL == tree_path) - { - GNUNET_break (0); - return; - } - if (! gtk_tree_model_get_iter (GTK_TREE_MODEL (ac->metadata), - &iter, tree_path)) - { - GNUNET_break (0); - gtk_tree_path_free (tree_path); - return; - } - gtk_tree_path_free (tree_path); - if ( (NULL != new_text) && - (0 != strlen (new_text)) ) - gtk_list_store_set (ac->metadata, &iter, - METADATA_MC_VALUE, new_text, - -1); - else - gtk_list_store_remove (ac->metadata, &iter); -} - - -/** - * User edited the 'value' field for inserting meta data. Update - * sensitivity of the 'add' button accordingly. - * - * @param editable the widget that was edited - * @param user_data the 'struct AdvertiseContext' - */ -void -GNUNET_GTK_identity_advertise_metadata_value_entry_changed_cb (GtkEditable *editable, - gpointer user_data) -{ - struct AdvertiseContext *ac = user_data; - const char *value; - GtkEntry *value_entry; - GtkWidget * add_button; - - value_entry = GTK_ENTRY (gtk_builder_get_object (ac->builder, - "GNUNET_GTK_identity_advertise_metadata_value_entry")); - value = gtk_entry_get_text (value_entry); - add_button = GTK_WIDGET (gtk_builder_get_object (ac->builder, - "GNUNET_GTK_identity_advertise_metadata_add_button")); - if ( (NULL == value) || - (0 == strlen (value)) ) - { - gtk_widget_set_sensitive (add_button, - FALSE); - return; - } - gtk_widget_set_sensitive (add_button, - TRUE); -} - - -/** - * User clicked the 'add' button, get the type and value and update - * the metadata model. - * - * @param button the 'add' button - * @param user_data the 'struct AdvertiseContext' - */ -void -GNUNET_GTK_identity_advertise_metadata_add_button_clicked_cb (GtkButton * button, - gpointer user_data) -{ - struct AdvertiseContext *ac = user_data; - GtkTreeIter iter; - guint type; - const char *value; - GtkEntry *value_entry; - GtkComboBox *type_box; - - type_box = GTK_COMBO_BOX (gtk_builder_get_object (ac->builder, - "GNUNET_GTK_identity_advertise_metadata_type_combobox")); - if (! gtk_combo_box_get_active_iter (type_box, - &iter)) - { - GNUNET_break (0); - return; - } - gtk_tree_model_get (GTK_TREE_MODEL (ac->meta_types), - &iter, - METATYPES_MC_TYPE_AS_ENUM, &type, - -1); - value_entry = GTK_ENTRY (gtk_builder_get_object (ac->builder, - "GNUNET_GTK_identity_advertise_metadata_value_entry")); - value = gtk_entry_get_text (value_entry); - if ( (NULL == value) || - (0 == strlen (value)) ) - { - GNUNET_break (0); - return; - } - gtk_list_store_insert_with_values (ac->metadata, - &iter, 0, - METADATA_MC_TYPE_AS_ENUM, type, -#if HAVE_EXTRACTOR - METADATA_MC_TYPE_AS_STRING, EXTRACTOR_metatype_to_string (type), -#endif - METADATA_MC_VALUE, value, - -1); - gtk_entry_set_text (value_entry, ""); -} - - -/** - * Run the dialog for advertising a namespace. - * - * @param priv private key of the namespace to advertise - */ -void -GIG_advertise_dialog_start_ (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv) -{ - struct AdvertiseContext *ac; - gint i; - GtkTreeIter iter; - - ac = GNUNET_new (struct AdvertiseContext); - ac->priv = *priv; - ac->builder = - GNUNET_GTK_get_new_builder ("gnunet_identity_gtk_advertise_dialog.glade", - ac); - if (NULL == ac->builder) - { - GNUNET_break (0); - GNUNET_free (ac); - return; - } - GNUNET_GTK_setup_expiration_year_adjustment (ac->builder); - ac->dialog = GTK_WIDGET (gtk_builder_get_object - (ac->builder, "GNUNET_GTK_identity_advertise_dialog")); - ac->keywords = GTK_LIST_STORE (gtk_builder_get_object - (ac->builder, "GNUNET_GTK_identity_advertise_keywords_liststore")); - ac->metadata = GTK_LIST_STORE (gtk_builder_get_object - (ac->builder, "GNUNET_GTK_identity_advertise_metadata_liststore")); - ac->meta_types = GTK_LIST_STORE (gtk_builder_get_object - (ac->builder, "GNUNET_GTK_identity_metadata_types_liststore")); - for (i = 0; EXTRACTOR_METATYPE_RESERVED != types[i]; i++) - { - gtk_list_store_insert_with_values (ac->meta_types, - &iter, G_MAXINT, -#if HAVE_EXTRACTOR - METATYPES_MC_TYPE_AS_STRING, EXTRACTOR_metatype_to_string (types[i]), -#endif - METATYPES_MC_TYPE_AS_ENUM, types[i], - -1); - if (0 == i) - gtk_combo_box_set_active_iter (GTK_COMBO_BOX - (gtk_builder_get_object - (ac->builder, - "GNUNET_GTK_identity_advertise_metadata_type_combobox")), - &iter); - } - gtk_list_store_insert_with_values (ac->keywords, - &iter, G_MAXINT, - KEYWORDS_MC_KEYWORD, NEW_KEYWORD_TEXT, - -1); - gtk_window_present (GTK_WINDOW (ac->dialog)); -} - - -/* end of gnunet-identity-gtk_advertise.c */ diff --git a/src/identity/gnunet-identity-gtk_advertise.h b/src/identity/gnunet-identity-gtk_advertise.h deleted file mode 100644 index a9bcc5fb..00000000 --- a/src/identity/gnunet-identity-gtk_advertise.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - This file is part of GNUnet - Copyright (C) 2005-2013 GNUnet e.V. - - 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 3, 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., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -/** - * @file src/identity/gnunet-identity-gtk_advertise.h - * @author LRN - * @author Christian Grothoff - */ - -#ifndef GNUNET_IDENTITY_GTK_ADVERTISE_H -#define GNUNET_IDENTITY_GTK_ADVERTISE_H - -#include "gnunet_gtk.h" - - -/** - * Shutdown advertisement subsystem, this process is terminating. - */ -void -GIG_advertise_shutdown_ (void); - - -/** - * Run the dialog for advertising a namespace. - * - * @param priv private key of the namespace to advertise - */ -void -GIG_advertise_dialog_start_ (const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv); - -#endif -/* GNUNET_FS_GTK_NAMESPACE_MANAGER_H */ - -/* end of gnunet-identity-gtk_advertise.h */ -- cgit v1.2.3