[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r20768 - gnunet-gtk/src/gns
From: |
gnunet |
Subject: |
[GNUnet-SVN] r20768 - gnunet-gtk/src/gns |
Date: |
Mon, 26 Mar 2012 14:59:31 +0200 |
Author: wachs
Date: 2012-03-26 14:59:31 +0200 (Mon, 26 Mar 2012)
New Revision: 20768
Modified:
gnunet-gtk/src/gns/gnunet-gns-gtk.c
gnunet-gtk/src/gns/gnunet-gns-gtk.h
gnunet-gtk/src/gns/gnunet-gns-gtk_zone.c
Log:
- pseu fix
Modified: gnunet-gtk/src/gns/gnunet-gns-gtk.c
===================================================================
--- gnunet-gtk/src/gns/gnunet-gns-gtk.c 2012-03-26 12:41:53 UTC (rev 20767)
+++ gnunet-gtk/src/gns/gnunet-gns-gtk.c 2012-03-26 12:59:31 UTC (rev 20768)
@@ -151,7 +151,7 @@
const gchar * pseu;
pseu = gtk_entry_get_text (GTK_ENTRY(editable));
- if ((pseu != NULL) && (0 != strcmp ("", pseu)))
+ if ((pseu != NULL) && (0 != strcmp ("", pseu)) && (GNUNET_NO ==
gns->iteration))
{
rd.record_type = GNUNET_NAMESTORE_TYPE_PSEU;
@@ -160,7 +160,7 @@
rd.data_size = strlen (pseu) + 1;
rd.data = strdup (pseu);
GNUNET_NAMESTORE_record_create(gns->ns, gns->pkey, "+", &rd,
pseu_change_cont, gns);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New Pseudonym is `%s' %u\n", (char
*) rd.data, rd.data_size);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "New Pseudonym is `%s' %u\n", (char
*) rd.data, rd.data_size);
}
}
Modified: gnunet-gtk/src/gns/gnunet-gns-gtk.h
===================================================================
--- gnunet-gtk/src/gns/gnunet-gns-gtk.h 2012-03-26 12:41:53 UTC (rev 20767)
+++ gnunet-gtk/src/gns/gnunet-gns-gtk.h 2012-03-26 12:59:31 UTC (rev 20768)
@@ -49,7 +49,7 @@
struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pubkey;
struct GNUNET_CRYPTO_ShortHashCode zone;
-
+ int iteration;
};
Modified: gnunet-gtk/src/gns/gnunet-gns-gtk_zone.c
===================================================================
--- gnunet-gtk/src/gns/gnunet-gns-gtk_zone.c 2012-03-26 12:41:53 UTC (rev
20767)
+++ gnunet-gtk/src/gns/gnunet-gns-gtk_zone.c 2012-03-26 12:59:31 UTC (rev
20768)
@@ -28,6 +28,7 @@
#define NEW_NAME_STR "<new name>"
#define NEW_RECORD_STR "<new record>"
+#define ROOT_STR "+"
#define EXPIRE_NEVER_STRING "never"
#define EXPIRE_INVALID_STRING "invalid"
@@ -97,17 +98,20 @@
}
}
-void
+static void
check_name_validity_and_commit (struct GNUNET_GNS_Context *gns, gchar *path)
{
GtkTreeIter it;
GtkTreeIter parent;
+ int records;
int children;
+ int append_pseu;
int c;
int valid = GNUNET_YES;
char * name;
void * data;
size_t data_size;
+ const gchar * pseu;
char *n_name;
int n_type;
@@ -135,8 +139,20 @@
TREE_COL_NAME, &name,
-1);
- struct GNUNET_NAMESTORE_RecordData *rd = GNUNET_malloc (children * sizeof
(struct GNUNET_NAMESTORE_RecordData));
+ if (0 == strcmp (name, ROOT_STR))
+ {
+ /* We have to append PSEU RECORD */
+ append_pseu = GNUNET_YES;
+ records = children + 1;
+ }
+ else
+ {
+ append_pseu = GNUNET_NO;
+ records = children;
+ }
+ struct GNUNET_NAMESTORE_RecordData *rd = GNUNET_malloc (records * sizeof
(struct GNUNET_NAMESTORE_RecordData));
+
if (FALSE == gtk_tree_model_iter_children (gns->tm, &it, &parent))
return;
@@ -210,11 +226,34 @@
}
else
{
+
+ if (GNUNET_YES == append_pseu)
+ {
+ GNUNET_assert (children == (records -1));
+ /* Append PSEU record */
+ GtkEntry * entry = GTK_ENTRY (gtk_builder_get_object (gns->builder,
"GNUNET_GNS_GTK_pseu_entry"));
+ void *data;
+ size_t data_len;
+ pseu = gtk_entry_get_text (GTK_ENTRY(entry));
+ if (GNUNET_OK !=
GNUNET_NAMESTORE_string_to_value(GNUNET_NAMESTORE_TYPE_PSEU, pseu, &rd[records
- 1].data, &rd[records - 1].data_size))
+ {
+ GNUNET_break (0);
+ for (c = 0; c < records; c++)
+ GNUNET_free_non_null ((void *) rd[c].data);
+ GNUNET_free_non_null (rd);
+ }
+ rd[records - 1].record_type = GNUNET_NAMESTORE_TYPE_PSEU;
+ rd[records - 1].expiration = GNUNET_TIME_absolute_get_forever();
+ rd[records - 1].flags = GNUNET_NAMESTORE_RF_AUTHORITY |
GNUNET_NAMESTORE_RF_NONE;
+ g_free (pseu);
+
+ }
+
/* Remove old entries */
struct UpdateContext * uc = GNUNET_malloc (sizeof (struct UpdateContext));
uc->gns = gns;
uc->rd = rd;
- uc->rd_count = children;
+ uc->rd_count = records;
uc->name = strdup (name);
GNUNET_NAMESTORE_record_remove(gns->ns, gns->pkey, name, NULL,
&check_name_validity_and_commit_remove_proc, uc);
g_free (name);
@@ -346,7 +385,7 @@
g_free (n_value);
g_free (n_value_color);
}
- else if (0 != strcmp (name, "+"))
+ else if (0 != strcmp (name, ROOT_STR))
{
/* Removing the whole name record */
rcc = GNUNET_malloc(sizeof (struct Remove_Context));
@@ -962,8 +1001,8 @@
pseu_entry = GTK_ENTRY((gtk_builder_get_object (zc_ctx->gns->builder,
"GNUNET_GNS_GTK_pseu_entry")));
if (zc_ctx->label == NULL)
GNUNET_asprintf(&zc_ctx->label, "%s", EXPIRE_INVALID_STRING);
-
gtk_entry_set_text (pseu_entry, zc_ctx->label);
+ zc_ctx->gns->iteration = GNUNET_NO;
GNUNET_free (zc_ctx->label);
GNUNET_free (zc_ctx);
return;
@@ -1033,22 +1072,27 @@
if (NULL == type_str)
GNUNET_asprintf(&type_str, "%s", EXPIRE_INVALID_STRING);
- if (GNUNET_NAMESTORE_TYPE_PSEU == rd[c].record_type)
+ if ((0 ==strcmp (name, ROOT_STR)) && (GNUNET_NAMESTORE_TYPE_PSEU ==
rd[c].record_type))
+ {
zc_ctx->label = strdup(val);
-
- gtk_tree_store_insert_with_values(zc_ctx->gns->ts, &iter_record ,
&iter_name, 0,
- TREE_COL_NAME, name,
- TREE_COL_NAME_IS_VISIBLE, FALSE,
- TREE_COL_RECORD_TYPE, rd[c].record_type,
- TREE_COL_RECORD_TYPE_AS_STR, type_str,
- TREE_COL_IS_PUBLIC, public,
- TREE_COL_EXP_TIME, exp_t,
- TREE_COL_EXP_TIME_AS_STR, exp,
- TREE_COL_EXP_TIME_IS_REL,
time_is_relative,
- TREE_COL_VAL_AS_STR, val,
- TREE_COL_IS_RECORD_ROW, GNUNET_YES,
- TREE_COL_NOT_DUMMY_ROW, GNUNET_YES,
- -1);
+ zc_ctx->gns->iteration = GNUNET_YES;
+ }
+ else
+ {
+ gtk_tree_store_insert_with_values(zc_ctx->gns->ts, &iter_record ,
&iter_name, 0,
+ TREE_COL_NAME, name,
+ TREE_COL_NAME_IS_VISIBLE, FALSE,
+ TREE_COL_RECORD_TYPE,
rd[c].record_type,
+ TREE_COL_RECORD_TYPE_AS_STR, type_str,
+ TREE_COL_IS_PUBLIC, public,
+ TREE_COL_EXP_TIME, exp_t,
+ TREE_COL_EXP_TIME_AS_STR, exp,
+ TREE_COL_EXP_TIME_IS_REL,
time_is_relative,
+ TREE_COL_VAL_AS_STR, val,
+ TREE_COL_IS_RECORD_ROW, GNUNET_YES,
+ TREE_COL_NOT_DUMMY_ROW, GNUNET_YES,
+ -1);
+ }
GNUNET_free (type_str);
GNUNET_free (exp);
GNUNET_free (val);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r20768 - gnunet-gtk/src/gns,
gnunet <=