aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/gnunet-namestore-gtk.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-10-30 19:47:24 +0000
committerChristian Grothoff <christian@grothoff.org>2013-10-30 19:47:24 +0000
commit89ebafb9a1264e7a336cc348ce2c2426898da3a4 (patch)
tree93a7ec7c87fa49ef3d1f66047537ac49b9161b23 /src/namestore/gnunet-namestore-gtk.c
parent1a5f5d2d2a20fcf49ee203db2d627ff52165aaa2 (diff)
downloadgnunet-gtk-89ebafb9a1264e7a336cc348ce2c2426898da3a4.tar.gz
gnunet-gtk-89ebafb9a1264e7a336cc348ce2c2426898da3a4.zip
-finishing implementation of pluggable dialogs (#3081)
Diffstat (limited to 'src/namestore/gnunet-namestore-gtk.c')
-rw-r--r--src/namestore/gnunet-namestore-gtk.c587
1 files changed, 524 insertions, 63 deletions
diff --git a/src/namestore/gnunet-namestore-gtk.c b/src/namestore/gnunet-namestore-gtk.c
index eb08557b..4483b0c2 100644
--- a/src/namestore/gnunet-namestore-gtk.c
+++ b/src/namestore/gnunet-namestore-gtk.c
@@ -24,7 +24,8 @@
24 * @brief edit GNS zones 24 * @brief edit GNS zones
25 */ 25 */
26#include "gnunet_gtk.h" 26#include "gnunet_gtk.h"
27#include "gnunet-namestore-gtk_edit.h" 27#include "gnunet_gtk_namestore_plugin.h"
28#include <gmodule.h>
28#include <gnunet/gnunet_gnsrecord_lib.h> 29#include <gnunet/gnunet_gnsrecord_lib.h>
29#include <gnunet/gnunet_gns_service.h> 30#include <gnunet/gnunet_gns_service.h>
30#include <gnunet/gnunet_identity_service.h> 31#include <gnunet/gnunet_identity_service.h>
@@ -183,6 +184,25 @@ enum LIST_COLUMNS
183 184
184 185
185/** 186/**
187 * Columns in the zone list store.
188 */
189enum ZONE_COLUMNS
190{
191
192 /**
193 * A gchararray
194 */
195 ZONE_LS_NAME = 0,
196
197
198 /**
199 * A `struct GNUNET_IDENTITY_Ego`
200 */
201 ZONE_LS_EGO = 1
202};
203
204
205/**
186 * Closure for 'operation_done_cont'. 206 * Closure for 'operation_done_cont'.
187 */ 207 */
188struct OperationContext 208struct OperationContext
@@ -230,7 +250,7 @@ struct MoveOperationContext
230 /** 250 /**
231 * Info from editing dialog. 251 * Info from editing dialog.
232 */ 252 */
233 struct EditDialogContext *edc; 253 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc;
234 254
235 /** 255 /**
236 * Private key of target zone. 256 * Private key of target zone.
@@ -535,8 +555,8 @@ setup_qrcode ()
535 */ 555 */
536void 556void
537gnunet_namestore_gtk_qr_save_as_dialog_response_cb (GtkDialog *dialog, 557gnunet_namestore_gtk_qr_save_as_dialog_response_cb (GtkDialog *dialog,
538 gint response_id, 558 gint response_id,
539 gpointer user_data) 559 gpointer user_data)
540{ 560{
541#if HAVE_QRENCODE_H 561#if HAVE_QRENCODE_H
542 GtkBuilder *builder = user_data; 562 GtkBuilder *builder = user_data;
@@ -577,7 +597,7 @@ gnunet_namestore_gtk_qr_save_as_dialog_response_cb (GtkDialog *dialog,
577 */ 597 */
578void 598void
579gnunet_namestore_gtk_qr_saveas_button_clicked_cb (GtkButton *button, 599gnunet_namestore_gtk_qr_saveas_button_clicked_cb (GtkButton *button,
580 gpointer user_data) 600 gpointer user_data)
581{ 601{
582 GtkBuilder *builder; 602 GtkBuilder *builder;
583 GtkWindow *dialog; 603 GtkWindow *dialog;
@@ -589,7 +609,7 @@ gnunet_namestore_gtk_qr_saveas_button_clicked_cb (GtkButton *button,
589 pseu = gtk_entry_get_text (GTK_ENTRY(entry)); 609 pseu = gtk_entry_get_text (GTK_ENTRY(entry));
590 builder = 610 builder =
591 GNUNET_GTK_get_new_builder ("gnunet_namestore_gtk_qr_save_as_dialog.glade", 611 GNUNET_GTK_get_new_builder ("gnunet_namestore_gtk_qr_save_as_dialog.glade",
592 NULL); 612 NULL);
593 if (NULL == builder) 613 if (NULL == builder)
594 { 614 {
595 GNUNET_break (0); 615 GNUNET_break (0);
@@ -782,7 +802,7 @@ show_error_message (const char *title,
782 * @param edc resources to free 802 * @param edc resources to free
783 */ 803 */
784static void 804static void
785free_edit_dialog_context (struct EditDialogContext *edc) 805free_edit_dialog_context (struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc)
786{ 806{
787 g_free (edc->name); 807 g_free (edc->name);
788 g_free (edc->n_value); 808 g_free (edc->n_value);
@@ -804,7 +824,7 @@ merge_with_existing_records (void *cls,
804 const struct GNUNET_GNSRECORD_Data *rd) 824 const struct GNUNET_GNSRECORD_Data *rd)
805{ 825{
806 struct MoveOperationContext *moc = cls; 826 struct MoveOperationContext *moc = cls;
807 struct EditDialogContext *edc = moc->edc; 827 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc = moc->edc;
808 struct GNUNET_GNSRECORD_Data rd_new[rd_count + 1]; 828 struct GNUNET_GNSRECORD_Data rd_new[rd_count + 1];
809 struct OperationContext *oc; 829 struct OperationContext *oc;
810 830
@@ -883,7 +903,7 @@ handle_records_for_merge (void *cls,
883 * @param ret return code of the dialog 903 * @param ret return code of the dialog
884 */ 904 */
885static void 905static void
886edit_dialog_continuation (struct EditDialogContext *edc, 906edit_dialog_continuation (struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc,
887 GtkResponseType ret) 907 GtkResponseType ret)
888{ 908{
889 struct RecordInfo *ri = edc->ri; 909 struct RecordInfo *ri = edc->ri;
@@ -894,6 +914,17 @@ edit_dialog_continuation (struct EditDialogContext *edc,
894 size_t data_size; 914 size_t data_size;
895 struct OperationContext *oc; 915 struct OperationContext *oc;
896 916
917 if (NULL != edc->plugin)
918 {
919 GNUNET_PLUGIN_unload (edc->liblow,
920 edc->plugin);
921 edc->plugin = NULL;
922 }
923 if (NULL != edc->liblow)
924 {
925 GNUNET_free (edc->liblow);
926 edc->liblow = NULL;
927 }
897 if ( (NULL != ri) && 928 if ( (NULL != ri) &&
898 (GNUNET_OK != 929 (GNUNET_OK !=
899 GNUNET_GNSRECORD_records_deserialize (ri->data_size, 930 GNUNET_GNSRECORD_records_deserialize (ri->data_size,
@@ -1044,6 +1075,440 @@ edit_dialog_continuation (struct EditDialogContext *edc,
1044 1075
1045 1076
1046/** 1077/**
1078 * Disable 'save' button, dialog state is not acceptable.
1079 *
1080 * @param edc dialog to modify
1081 */
1082static void
1083edit_dialog_disable_save (struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc)
1084{
1085 gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (edc->builder,
1086 "edit_dialog_save_button")),
1087 FALSE);
1088}
1089
1090
1091/**
1092 * Enable 'save' button, dialog state is acceptable.
1093 *
1094 * @param edc dialog to modify
1095 */
1096static void
1097edit_dialog_enable_save (struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc)
1098{
1099 gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (edc->builder,
1100 "edit_dialog_save_button")),
1101 TRUE);
1102}
1103
1104
1105/**
1106 * Function that should be called by the plugin whenever values in
1107 * the dialog were edited. It will check the validity of the dialog
1108 * and update the "save" button accordingly.
1109 *
1110 * @param edc the plugin environment
1111 */
1112static void
1113check_validity (struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc)
1114{
1115
1116 GtkEditable *entry;
1117 const gchar *name;
1118
1119 /* check name */
1120 entry = GTK_EDITABLE (gtk_builder_get_object (edc->builder,
1121 "edit_dialog_name_entry"));
1122 name = gtk_editable_get_chars (entry, 0, -1);
1123 if ( (GNUNET_OK != edc->plugin->validate (edc->plugin->cls,
1124 edc->builder)) ||
1125 ( (GNUNET_SYSERR == GNUNET_DNSPARSER_check_label (name)) &&
1126 (0 != strcmp (name, GNUNET_GNS_MASTERZONE_STR))) )
1127 {
1128 edit_dialog_disable_save (edc);
1129 return;
1130 }
1131 edit_dialog_enable_save (edc);
1132}
1133
1134
1135/**
1136 * Setup the zone combobox.
1137 *
1138 * @param edc dialog to setup the combo box for
1139 */
1140static void
1141setup_zone (struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc)
1142{
1143 GtkTreeIter iter;
1144 GtkComboBox *cb;
1145 gchar *name;
1146
1147 cb = GTK_COMBO_BOX (gtk_builder_get_object (edc->builder,
1148 "edit_dialog_zone_combobox"));
1149
1150 gtk_combo_box_set_model (cb,
1151 GTK_TREE_MODEL (edc->zone_liststore));
1152 GNUNET_assert (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (edc->zone_liststore),
1153 &iter));
1154 do {
1155 gtk_tree_model_get (GTK_TREE_MODEL (edc->zone_liststore),
1156 &iter,
1157 ZONE_LS_NAME, &name,
1158 -1);
1159 if (0 == strcmp (name,
1160 edc->new_zone_option))
1161 {
1162 g_free (name);
1163 break;
1164 }
1165 g_free (name);
1166 } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (edc->zone_liststore),
1167 &iter));
1168 gtk_combo_box_set_active_iter (cb,
1169 &iter);
1170}
1171
1172
1173/**
1174 * Initialize widgets of the edit dialog that are the same regardless of
1175 * the type of the record.
1176 *
1177 * @param edc dialog context
1178 */
1179static void
1180edit_dialog_setup_common_elements (struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc)
1181{
1182 GtkComboBox *cb;
1183 GtkListStore *ls;
1184 GtkTreeIter iter;
1185 struct GNUNET_TIME_Absolute at;
1186 struct GNUNET_TIME_Relative rt;
1187 time_t tp;
1188 struct tm *ymd;
1189 GtkCalendar *cal;
1190
1191 if (GNUNET_YES !=
1192 edc->old_record_in_namestore)
1193 {
1194 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
1195 "edit_dialog_delete_button")));
1196 edit_dialog_disable_save (edc);
1197 }
1198 gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (edc->builder,
1199 "edit_dialog_name_entry")),
1200 edc->name);
1201 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
1202 "edit_dialog_options_public_checkbutton")),
1203 edc->n_public);
1204 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
1205 "edit_dialog_options_shadow_checkbutton")),
1206 edc->n_is_shadow);
1207 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == edc->n_exp_time)
1208 {
1209 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
1210 "edit_dialog_expiration_never_radiobutton")),
1211 TRUE);
1212 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
1213 "edit_dialog_expiration_absolute_calendar")));
1214 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
1215 "edit_dialog_expiration_absolute_hbox")));
1216 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
1217 "edit_dialog_expiration_relative_combobox")));
1218 }
1219 if ( (edc->n_is_relative) &&
1220 (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != edc->n_exp_time) )
1221 {
1222 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
1223 "edit_dialog_expiration_relative_radiobutton")),
1224 TRUE);
1225 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
1226 "edit_dialog_expiration_absolute_calendar")));
1227 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
1228 "edit_dialog_expiration_absolute_hbox")));
1229 rt.rel_value_us = edc->n_exp_time;
1230 }
1231 else
1232 {
1233 /* select a sane default */
1234 rt = GNUNET_TIME_UNIT_DAYS;
1235 }
1236 cb = GTK_COMBO_BOX (gtk_builder_get_object (edc->builder,
1237 "edit_dialog_expiration_relative_combobox"));
1238 ls = GTK_LIST_STORE (gtk_combo_box_get_model (cb));
1239 gtk_list_store_insert_with_values (ls, &iter,
1240 -1 /* position: append */,
1241 0, GNUNET_STRINGS_relative_time_to_string (rt, GNUNET_NO),
1242 -1);
1243 gtk_combo_box_set_active_iter (cb, &iter);
1244 if ( (! edc->n_is_relative) &&
1245 (GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us != edc->n_exp_time) )
1246 {
1247 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
1248 "edit_dialog_expiration_absolute_radiobutton")),
1249 TRUE);
1250
1251 gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (edc->builder,
1252 "edit_dialog_expiration_relative_combobox")));
1253 at.abs_value_us = edc->n_exp_time;
1254 }
1255 else
1256 {
1257 /* select a sane default: right now */
1258 at = GNUNET_TIME_absolute_get ();
1259 }
1260 tp = (time_t) (at.abs_value_us / 1000000LL); /* convert to seconds */
1261 ymd = gmtime (&tp);
1262 cal = GTK_CALENDAR (gtk_builder_get_object (edc->builder,
1263 "edit_dialog_expiration_absolute_calendar"));
1264 gtk_calendar_select_month (cal,
1265 ymd->tm_mon,
1266 ymd->tm_year + 1900);
1267 gtk_calendar_mark_day (cal,
1268 ymd->tm_mday);
1269 gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
1270 "edit_dialog_expiration_absolute_hours_spinbutton")),
1271 (double) ymd->tm_hour);
1272 gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
1273 "edit_dialog_expiration_absolute_minutes_spinbutton")),
1274 (double) ymd->tm_min);
1275 gtk_spin_button_set_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
1276 "edit_dialog_expiration_absolute_seconds_spinbutton")),
1277 (double) ymd->tm_sec);
1278}
1279
1280
1281/**
1282 * Perform the reverse of the #edit_dialog_setup_common_elements() function,
1283 * that is, extract the values from the (common) widgets and store the
1284 * values in @a edc.
1285 *
1286 * @param edc edit dialog to extract data from
1287 */
1288static void
1289edit_dialog_putes_common_elements (struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc)
1290{
1291 const char *rt_s;
1292 struct GNUNET_TIME_Relative rt;
1293 GtkComboBox *cb;
1294 GtkTreeModel *tm;
1295 GtkTreeIter iter;
1296 gchar *opt;
1297 struct GNUNET_IDENTITY_Ego *ego;
1298
1299 /* is public flag */
1300 edc->n_public = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
1301 "edit_dialog_options_public_checkbutton")));
1302 /* is shadow flag */
1303 edc->n_is_shadow = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
1304 "edit_dialog_options_shadow_checkbutton")));
1305
1306 /* 'forever' expiration time */
1307 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
1308 "edit_dialog_expiration_never_radiobutton"))))
1309 {
1310 edc->n_exp_time = GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us;
1311 edc->n_is_relative = TRUE; /* doesn't matter, but make sure it is well-defined anyway */
1312 }
1313
1314 /* 'relative' expiration time */
1315 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
1316 "edit_dialog_expiration_relative_radiobutton"))))
1317 {
1318 cb = GTK_COMBO_BOX (gtk_builder_get_object (edc->builder,
1319 "edit_dialog_expiration_relative_combobox"));
1320 tm = gtk_combo_box_get_model (cb);
1321 if (! gtk_combo_box_get_active_iter (cb, &iter))
1322 {
1323 GNUNET_break (0);
1324 return;
1325 }
1326 gtk_tree_model_get (tm, &iter,
1327 0, &rt_s,
1328 -1);
1329 GNUNET_break (GNUNET_YES ==
1330 GNUNET_STRINGS_fancy_time_to_relative (rt_s,
1331 &rt));
1332 edc->n_exp_time = rt.rel_value_us;
1333 edc->n_is_relative = TRUE;
1334 }
1335
1336 /* 'absolute' expiration time */
1337 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_builder_get_object (edc->builder,
1338 "edit_dialog_expiration_absolute_radiobutton"))))
1339 {
1340 guint year;
1341 guint month;
1342 guint day;
1343 guint hour;
1344 guint minute;
1345 guint second;
1346 char fancydate[128];
1347 struct GNUNET_TIME_Absolute atime;
1348
1349 gtk_calendar_get_date (GTK_CALENDAR (gtk_builder_get_object (edc->builder,
1350 "edit_dialog_expiration_absolute_calendar")),
1351 &year, &month, &day);
1352 hour = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
1353 "edit_dialog_expiration_absolute_hours_spinbutton")));
1354 minute = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
1355 "edit_dialog_expiration_absolute_minutes_spinbutton")));
1356 second = gtk_spin_button_get_value (GTK_SPIN_BUTTON (gtk_builder_get_object (edc->builder,
1357 "edit_dialog_expiration_absolute_seconds_spinbutton")));
1358 GNUNET_snprintf (fancydate,
1359 sizeof (fancydate),
1360 "%u-%u-%u %u:%u:%u",
1361 (unsigned int) year,
1362 (unsigned int) month + 1,
1363 (unsigned int) day,
1364 (unsigned int) hour,
1365 (unsigned int) minute,
1366 (unsigned int) second);
1367 GNUNET_break (GNUNET_OK ==
1368 GNUNET_STRINGS_fancy_time_to_absolute (fancydate,
1369 &atime));
1370 edc->n_exp_time = atime.abs_value_us;
1371 edc->n_is_relative = FALSE;
1372 }
1373
1374 /* extract target zone! */
1375 cb = GTK_COMBO_BOX (gtk_builder_get_object (edc->builder,
1376 "edit_dialog_zone_combobox"));
1377 tm = gtk_combo_box_get_model (cb);
1378 if (! gtk_combo_box_get_active_iter (cb, &iter))
1379 {
1380 GNUNET_break (0);
1381 }
1382 else
1383 {
1384 gtk_tree_model_get (tm, &iter,
1385 ZONE_LS_NAME, &opt,
1386 ZONE_LS_EGO, &ego,
1387 -1);
1388 if (NULL == opt)
1389 {
1390 GNUNET_break (0);
1391 }
1392 else
1393 {
1394 g_free (edc->new_zone_option);
1395 edc->new_zone_option = g_strdup (opt);
1396 g_free (opt);
1397 edc->ego = ego;
1398 }
1399 }
1400}
1401
1402
1403/**
1404 * Editing dialog was closed, get the data and call the
1405 * continuation.
1406 *
1407 * @param dialog editing dialog
1408 * @param response_id action that caused the dialog to be closed
1409 * @param user_data the `struct GNUNET_GTK_NAMESTORE_PluginEnvironment`
1410 */
1411static void
1412edit_dialog_response_cb (GtkDialog *dialog,
1413 gint response_id,
1414 gpointer user_data)
1415{
1416 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc = user_data;
1417
1418 if (GTK_RESPONSE_OK == response_id)
1419 {
1420 edit_dialog_putes_common_elements (edc);
1421 g_free (edc->n_value);
1422 edc->n_value = edc->plugin->store (edc->plugin->cls,
1423 edc->builder);
1424 }
1425 gtk_widget_destroy (GTK_WIDGET (edc->dialog));
1426 g_object_unref (edc->builder);
1427 edc->builder = NULL;
1428 edit_dialog_continuation (edc, response_id);
1429}
1430
1431
1432/**
1433 * Callback invoked from #GNUNET_GTK_get_new_builder2 to give
1434 * us a chance to add symbols from the plugin.
1435 *
1436 * @param builder the builder under construction
1437 * @param object object to bind signal to
1438 * @param signal_name name of the signal
1439 * @param handler_name name of the handler
1440 * @param connect_object a GObject, if non-NULL, use g_signal_connect_object()
1441 * @param flags GConnectFlags to use
1442 * @param user_data the `struct GNUNET_GTK_NAMESTORE_PluginEnvironment *`
1443 */
1444static void
1445add_symbols (GtkBuilder *builder,
1446 GObject *object,
1447 const gchar *signal_name,
1448 const gchar *handler_name,
1449 GObject *connect_object,
1450 GConnectFlags flags,
1451 gpointer user_data)
1452
1453{
1454 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc = user_data;
1455 unsigned int i;
1456 GCallback cb;
1457 GModule *m;
1458
1459 cb = NULL;
1460 if (NULL != edc->plugin->symbols)
1461 {
1462 for (i=0; NULL != edc->plugin->symbols[i].name; i++)
1463 {
1464 if (0 == strcmp (handler_name,
1465 edc->plugin->symbols[i].name))
1466 {
1467 cb = edc->plugin->symbols[i].cb;
1468 break;
1469 }
1470 }
1471 }
1472 if (NULL == cb)
1473 {
1474 m = g_module_open (NULL, 0);
1475 if (! g_module_symbol (m,
1476 handler_name,
1477 (void **) &cb))
1478 {
1479 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1480 _("Failed to find handler `%s'\n"),
1481 handler_name);
1482 g_module_close (m);
1483 return;
1484 }
1485 g_module_close (m);
1486 }
1487 if (NULL != connect_object)
1488 g_signal_connect_object (object,
1489 signal_name,
1490 cb,
1491 connect_object,
1492 flags);
1493 else if (flags & G_CONNECT_SWAPPED)
1494 g_signal_connect_swapped (object,
1495 signal_name,
1496 cb,
1497 user_data);
1498 else if (flags & G_CONNECT_AFTER)
1499 g_signal_connect_after (object,
1500 signal_name,
1501 cb,
1502 user_data);
1503 else
1504 g_signal_connect (object,
1505 signal_name,
1506 cb,
1507 user_data);
1508}
1509
1510
1511/**
1047 * Launch a record editing dialog. 1512 * Launch a record editing dialog.
1048 * 1513 *
1049 * @param n_type type of the record to edit 1514 * @param n_type type of the record to edit
@@ -1059,9 +1524,9 @@ launch_edit_dialog (gint n_type,
1059 struct RecordInfo *ri, 1524 struct RecordInfo *ri,
1060 unsigned int off) 1525 unsigned int off)
1061{ 1526{
1062 struct EditDialogContext *edc; 1527 struct GNUNET_GTK_NAMESTORE_PluginEnvironment *edc;
1063 1528
1064 edc = GNUNET_new (struct EditDialogContext); 1529 edc = GNUNET_new (struct GNUNET_GTK_NAMESTORE_PluginEnvironment);
1065 if ( (NULL != ri) && 1530 if ( (NULL != ri) &&
1066 (off < ri->rd_count) ) 1531 (off < ri->rd_count) )
1067 { 1532 {
@@ -1090,56 +1555,52 @@ launch_edit_dialog (gint n_type,
1090 edc->name = GNUNET_strdup (name); 1555 edc->name = GNUNET_strdup (name);
1091 edc->new_zone_option = g_strdup (current_zone_option); 1556 edc->new_zone_option = g_strdup (current_zone_option);
1092 edc->record_type = n_type; 1557 edc->record_type = n_type;
1093 edc->cont = &edit_dialog_continuation;
1094 edc->zone_liststore = zone_liststore; 1558 edc->zone_liststore = zone_liststore;
1095 switch (n_type) 1559 edc->check_validity = &check_validity;
1560 GNUNET_asprintf (&edc->liblow,
1561 "libgnunet_plugin_gtk_namestore_%s",
1562 GNUNET_GNSRECORD_number_to_typename (n_type));
1563 GNUNET_STRINGS_utf8_tolower (edc->liblow,
1564 edc->liblow);
1565 edc->plugin = GNUNET_PLUGIN_load (edc->liblow, edc);
1566 if (NULL == edc->plugin)
1096 { 1567 {
1097 case GNUNET_DNSPARSER_TYPE_A: 1568 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1098 GNS_edit_dialog_a (edc); 1569 _("Failed to load plugin for record type %d\n"),
1099 break; 1570 (int) n_type);
1100 case GNUNET_DNSPARSER_TYPE_AAAA:
1101 GNS_edit_dialog_aaaa (edc);
1102 break;
1103 case GNUNET_DNSPARSER_TYPE_CNAME:
1104 GNS_edit_dialog_cname (edc);
1105 break;
1106 case GNUNET_GNSRECORD_TYPE_LEHO:
1107 GNS_edit_dialog_leho (edc);
1108 break;
1109 case GNUNET_GNSRECORD_TYPE_PHONE:
1110 GNS_edit_dialog_phone (edc);
1111 break;
1112 case GNUNET_GNSRECORD_TYPE_PKEY:
1113 GNS_edit_dialog_pkey (edc);
1114 break;
1115 case GNUNET_DNSPARSER_TYPE_PTR:
1116 GNS_edit_dialog_ptr (edc);
1117 break;
1118 case GNUNET_DNSPARSER_TYPE_MX:
1119 GNS_edit_dialog_mx (edc);
1120 break;
1121 case GNUNET_GNSRECORD_TYPE_GNS2DNS:
1122 GNS_edit_dialog_gns2dns (edc);
1123 break;
1124 case GNUNET_DNSPARSER_TYPE_SOA:
1125 GNS_edit_dialog_soa (edc);
1126 break;
1127 case GNUNET_DNSPARSER_TYPE_SRV:
1128 GNS_edit_dialog_srv (edc);
1129 break;
1130 case GNUNET_DNSPARSER_TYPE_TXT:
1131 GNS_edit_dialog_txt (edc);
1132 break;
1133 case GNUNET_GNSRECORD_TYPE_VPN:
1134 GNS_edit_dialog_vpn (edc);
1135 break;
1136 case GNUNET_DNSPARSER_TYPE_TLSA:
1137 default:
1138 GNUNET_break (0);
1139 edit_dialog_continuation (edc, 1571 edit_dialog_continuation (edc,
1140 GTK_RESPONSE_CANCEL); 1572 GTK_RESPONSE_CANCEL);
1141 break; 1573 return;
1142 } 1574 }
1575 edc->builder = GNUNET_GTK_get_new_builder2 (edc->plugin->dialog_glade_filename,
1576 edc,
1577 &add_symbols);
1578 if (NULL == edc->builder)
1579 {
1580 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1581 _("Failed to load dialog resource `%s'\n"),
1582 edc->plugin->dialog_glade_filename);
1583 edit_dialog_continuation (edc, GTK_RESPONSE_CANCEL);
1584 return;
1585 }
1586 if (GNUNET_YES ==
1587 edc->old_record_in_namestore)
1588 {
1589 edc->plugin->load (edc->plugin->cls,
1590 edc->n_value,
1591 edc->builder);
1592 }
1593 edc->dialog = GTK_DIALOG (gtk_builder_get_object (edc->builder,
1594 edc->plugin->dialog_widget_name));
1595 g_signal_connect (edc->dialog,
1596 "response",
1597 G_CALLBACK (&edit_dialog_response_cb),
1598 edc);
1599 edit_dialog_setup_common_elements (edc);
1600 setup_zone (edc);
1601 gtk_dialog_set_default_response (edc->dialog,
1602 GTK_RESPONSE_OK);
1603 gtk_window_present (GTK_WINDOW (edc->dialog));
1143} 1604}
1144 1605
1145 1606
@@ -1186,7 +1647,7 @@ check_permissions (struct RecordInfo *ri,
1186 */ 1647 */
1187void 1648void
1188gnunet_namestore_gtk_popup_edit_button_activate_cb (GtkWidget *widget, 1649gnunet_namestore_gtk_popup_edit_button_activate_cb (GtkWidget *widget,
1189 gpointer user_data) 1650 gpointer user_data)
1190{ 1651{
1191 GtkTreeSelection *sel; 1652 GtkTreeSelection *sel;
1192 gint n_type; 1653 gint n_type;
@@ -1239,9 +1700,9 @@ gnunet_namestore_gtk_popup_edit_button_activate_cb (GtkWidget *widget,
1239 */ 1700 */
1240void 1701void
1241gnunet_namestore_gtk_type_cellrenderercombo_edited_cb (GtkCellRendererText *text, 1702gnunet_namestore_gtk_type_cellrenderercombo_edited_cb (GtkCellRendererText *text,
1242 gchar *path_string, 1703 gchar *path_string,
1243 gchar *new_text, 1704 gchar *new_text,
1244 gpointer user_data) 1705 gpointer user_data)
1245{ 1706{
1246 GtkTreeIter it; 1707 GtkTreeIter it;
1247 guint type; 1708 guint type;
@@ -2281,7 +2742,8 @@ main (int argc, char *const *argv)
2281 if (GNUNET_OK == 2742 if (GNUNET_OK ==
2282 GNUNET_GTK_main_loop_start ("gnunet-namestore-gtk", 2743 GNUNET_GTK_main_loop_start ("gnunet-namestore-gtk",
2283 "gnunet-namestore-gtk", argc, argv, 2744 "gnunet-namestore-gtk", argc, argv,
2284 options, "gnunet_namestore_gtk_main_window.glade", 2745 options,
2746 "gnunet_namestore_gtk_main_window.glade",
2285 &run)) 2747 &run))
2286 ret = gret; 2748 ret = gret;
2287 else 2749 else
@@ -2290,5 +2752,4 @@ main (int argc, char *const *argv)
2290} 2752}
2291 2753
2292 2754
2293
2294/* end of gnunet-namestore-gtk.c */ 2755/* end of gnunet-namestore-gtk.c */