diff options
Diffstat (limited to 'src/fs/gnunet-fs-gtk_advertise-pseudonym.c')
-rw-r--r-- | src/fs/gnunet-fs-gtk_advertise-pseudonym.c | 175 |
1 files changed, 0 insertions, 175 deletions
diff --git a/src/fs/gnunet-fs-gtk_advertise-pseudonym.c b/src/fs/gnunet-fs-gtk_advertise-pseudonym.c deleted file mode 100644 index 388aa22b..00000000 --- a/src/fs/gnunet-fs-gtk_advertise-pseudonym.c +++ /dev/null | |||
@@ -1,175 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | (C) 2005-2013 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file src/fs/gnunet-fs-gtk_advertise-pseudonym.c | ||
23 | * @author Christian Grothoff | ||
24 | * @brief allow the user to select a pseudonym to advertise and | ||
25 | * then run the advertising dialog (using the edit-publish | ||
26 | * dialog functions) and finally do the advertising | ||
27 | */ | ||
28 | #include "gnunet-fs-gtk_common.h" | ||
29 | #include "gnunet-fs-gtk.h" | ||
30 | #include "gnunet-fs-gtk_publish-edit-dialog.h" | ||
31 | #include "gnunet-fs-gtk_advertise-pseudonym.h" | ||
32 | |||
33 | |||
34 | /** | ||
35 | * Columns in the select pseudonym model. | ||
36 | */ | ||
37 | enum FS_SelectPseudonymModelColumns | ||
38 | { | ||
39 | /** | ||
40 | * A gchararray | ||
41 | */ | ||
42 | FS_SELECT_PSEUDONYM_NAMESPACE_MC_NAME = 0, | ||
43 | |||
44 | /** | ||
45 | * A gpointer | ||
46 | */ | ||
47 | FS_SELECT_PSEUDONYM_NAMESPACE_MC_HANDLE = 1, | ||
48 | }; | ||
49 | |||
50 | |||
51 | /* *************************** handlers run on closing of the dialog ********************** */ | ||
52 | |||
53 | |||
54 | /** | ||
55 | * Closure for 'advertise_namespace' and the callback from the editing dialog. | ||
56 | */ | ||
57 | struct NamespaceAdvertisementContext | ||
58 | { | ||
59 | /** | ||
60 | * Handle to the namespace to advertise. | ||
61 | */ | ||
62 | struct GNUNET_CRYPTO_EccPrivateKey ns; | ||
63 | |||
64 | /** | ||
65 | * Root of the namespace is stored here temporarily. | ||
66 | */ | ||
67 | const char *root; | ||
68 | |||
69 | /** | ||
70 | * File information structure (fake) which we use to run the 'edit' dialog. | ||
71 | */ | ||
72 | struct GNUNET_FS_FileInformation *fip; | ||
73 | }; | ||
74 | |||
75 | |||
76 | /** | ||
77 | * Actually perform the advertising with the information collected. | ||
78 | * | ||
79 | * @param cls closure, a 'struct NamespaceAdvertisementContext *' | ||
80 | * @param fi the entry in the publish-structure | ||
81 | * @param length length of the file or directory | ||
82 | * @param meta metadata for the file or directory (can be modified) | ||
83 | * @param uri pointer to the keywords that will be used for this entry (can be modified) | ||
84 | * @param bo block options (can be modified) | ||
85 | * @param do_index should we index (can be modified) | ||
86 | * @param client_info pointer to client context set upon creation (can be modified) | ||
87 | * @return GNUNET_OK to continue, GNUNET_NO to remove | ||
88 | * this entry from the directory, GNUNET_SYSERR | ||
89 | * to abort the iteration | ||
90 | */ | ||
91 | static int | ||
92 | advertise_namespace (void *cls, | ||
93 | struct GNUNET_FS_FileInformation *fi, | ||
94 | uint64_t length, struct GNUNET_CONTAINER_MetaData *meta, | ||
95 | struct GNUNET_FS_Uri **uri, | ||
96 | struct GNUNET_FS_BlockOptions *bo, int *do_index, | ||
97 | void **client_info) | ||
98 | { | ||
99 | struct NamespaceAdvertisementContext *nds = cls; | ||
100 | struct GNUNET_FS_Uri *sks_uri; | ||
101 | struct GNUNET_CRYPTO_EccPublicKey pub; | ||
102 | |||
103 | GNUNET_CRYPTO_ecc_key_get_public (&nds->ns, &pub); | ||
104 | sks_uri = GNUNET_FS_uri_sks_create (&pub, nds->root); | ||
105 | GNUNET_FS_publish_ksk (GNUNET_FS_GTK_get_fs_handle (), | ||
106 | *uri, meta, sks_uri, | ||
107 | bo, GNUNET_FS_PUBLISH_OPTION_NONE, | ||
108 | NULL, NULL); | ||
109 | GNUNET_FS_uri_destroy (sks_uri); | ||
110 | return GNUNET_SYSERR; | ||
111 | } | ||
112 | |||
113 | |||
114 | /** | ||
115 | * Callback invoked from the editing dialog upon completion of the | ||
116 | * meta data editing for the advertisement. | ||
117 | * | ||
118 | * @param cls the 'struct NamespaceAdvertisementContext' | ||
119 | * @param ret return value from the dialog | ||
120 | * @param root namespace root to use | ||
121 | */ | ||
122 | static void | ||
123 | adv_pseudonym_edit_publish_dialog_cb (gpointer cls, | ||
124 | gint ret, | ||
125 | const char *root) | ||
126 | { | ||
127 | struct NamespaceAdvertisementContext *nds = cls; | ||
128 | |||
129 | if (ret == GTK_RESPONSE_OK) | ||
130 | { | ||
131 | nds->root = root; | ||
132 | GNUNET_FS_file_information_inspect (nds->fip, &advertise_namespace, nds); | ||
133 | nds->root = NULL; | ||
134 | } | ||
135 | GNUNET_FS_file_information_destroy (nds->fip, NULL, NULL); | ||
136 | GNUNET_free (nds); | ||
137 | } | ||
138 | |||
139 | |||
140 | /** | ||
141 | * Call the publication editor dialog in namespace advertising mode, | ||
142 | * and publish the namespace when it's OK'ed. | ||
143 | * | ||
144 | * @param ns namespace to advertise | ||
145 | * @param transient_for parent window for the dialog | ||
146 | */ | ||
147 | void | ||
148 | GNUNET_FS_GTK_advertise_namespace (const struct GNUNET_CRYPTO_EccPrivateKey *ns, | ||
149 | GtkWindow *transient_for) | ||
150 | { | ||
151 | struct NamespaceAdvertisementContext *nds; | ||
152 | struct GNUNET_FS_BlockOptions bo; | ||
153 | struct GNUNET_CONTAINER_MetaData *meta; | ||
154 | |||
155 | nds = GNUNET_new (struct NamespaceAdvertisementContext); | ||
156 | nds->ns = *ns; | ||
157 | memset (&bo, 0, sizeof (struct GNUNET_FS_BlockOptions)); | ||
158 | bo.expiration_time = GNUNET_FS_year_to_time (GNUNET_FS_get_current_year () + 2); | ||
159 | bo.anonymity_level = 1; | ||
160 | bo.content_priority = 1000; | ||
161 | /* create fake file information to run the 'edit' dialog with */ | ||
162 | meta = GNUNET_CONTAINER_meta_data_create (); | ||
163 | nds->fip = | ||
164 | GNUNET_FS_file_information_create_empty_directory (NULL, NULL, NULL, meta, | ||
165 | &bo, NULL); | ||
166 | GNUNET_CONTAINER_meta_data_destroy (meta); | ||
167 | GNUNET_FS_GTK_edit_publish_dialog (transient_for, | ||
168 | nds->fip, | ||
169 | GNUNET_YES, | ||
170 | &adv_pseudonym_edit_publish_dialog_cb, | ||
171 | nds); | ||
172 | } | ||
173 | |||
174 | |||
175 | /* end of gnunet-fs-gtk_advertise-pseudonym.c */ | ||