diff options
-rw-r--r-- | configure.ac | 32 | ||||
-rw-r--r-- | contrib/Makefile.am | 1 | ||||
-rw-r--r-- | contrib/gnunet_setup_gtk_main_window.glade | 60 | ||||
-rw-r--r-- | contrib/qr_dummy.png | bin | 0 -> 239 bytes | |||
-rw-r--r-- | src/setup/Makefile.am | 2 | ||||
-rw-r--r-- | src/setup/gnunet-setup-gns.c | 112 |
6 files changed, 173 insertions, 34 deletions
diff --git a/configure.ac b/configure.ac index 14f0e4cf..14ecba3d 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -175,6 +175,33 @@ then | |||
175 | fi | 175 | fi |
176 | 176 | ||
177 | 177 | ||
178 | # test for libqrencode | ||
179 | qrencode=0 | ||
180 | QR_LIBS="-lqrencode" | ||
181 | AC_MSG_CHECKING(for libqrencode) | ||
182 | AC_ARG_WITH(qrencode, | ||
183 | [ --with-qrencode=PFX Base of libqrencode installation], | ||
184 | [AC_MSG_RESULT([$with_extractor]) | ||
185 | case $with_qrencode in | ||
186 | no) | ||
187 | ;; | ||
188 | yes) | ||
189 | AC_CHECK_HEADERS(qrencode.h,qrencode=1) | ||
190 | ;; | ||
191 | *) | ||
192 | CPPFLAGS="-I$with_qrencode/include $CPPFLAGS" | ||
193 | QR_CFLAGS="-I$with_qrencode/include" | ||
194 | QR_LIBS="-L$with_qrencode/lib -lqrencode" | ||
195 | AC_CHECK_HEADERS(qrencode.h,qrencode=1) | ||
196 | ;; | ||
197 | esac | ||
198 | ], | ||
199 | [AC_MSG_RESULT([--with-qrencode not specified]) | ||
200 | AC_CHECK_HEADERS(qrencode.h,qrencode=1)]) | ||
201 | |||
202 | AC_SUBST(QR_CFLAGS) | ||
203 | AC_SUBST(QR_LIBS) | ||
204 | |||
178 | AC_MSG_CHECKING(for gtk) | 205 | AC_MSG_CHECKING(for gtk) |
179 | check_for_3=3.0.0 | 206 | check_for_3=3.0.0 |
180 | check_for_2=false | 207 | check_for_2=false |
@@ -482,3 +509,8 @@ contrib/gnunet_peerinfo_gtk_about_window.glade | |||
482 | contrib/gnunet_statistics_gtk_about_window.glade | 509 | contrib/gnunet_statistics_gtk_about_window.glade |
483 | contrib/gnunet_setup_about_window.glade | 510 | contrib/gnunet_setup_about_window.glade |
484 | ]) | 511 | ]) |
512 | |||
513 | if test "$qrencode" != 1 | ||
514 | then | ||
515 | AC_MSG_WARN([gnunet-setup will not include QR support]) | ||
516 | fi | ||
diff --git a/contrib/Makefile.am b/contrib/Makefile.am index 41ba4a06..ce834e51 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am | |||
@@ -15,6 +15,7 @@ EXTRA_DIST = \ | |||
15 | $(IMAGES) | 15 | $(IMAGES) |
16 | 16 | ||
17 | pkgdata_DATA = \ | 17 | pkgdata_DATA = \ |
18 | qr_dummy.png \ | ||
18 | downloading.gif \ | 19 | downloading.gif \ |
19 | downloading_not_receiving.gif \ | 20 | downloading_not_receiving.gif \ |
20 | downloaded.gif \ | 21 | downloaded.gif \ |
diff --git a/contrib/gnunet_setup_gtk_main_window.glade b/contrib/gnunet_setup_gtk_main_window.glade index a0307c3a..ebf3f293 100644 --- a/contrib/gnunet_setup_gtk_main_window.glade +++ b/contrib/gnunet_setup_gtk_main_window.glade | |||
@@ -4480,7 +4480,7 @@ | |||
4480 | </packing> | 4480 | </packing> |
4481 | </child> | 4481 | </child> |
4482 | <child> | 4482 | <child> |
4483 | <object class="GtkVSeparator" id="vseparator3"> | 4483 | <object class="GtkVSeparator" id="GNUNET_setup_qr_vseparator"> |
4484 | <property name="visible">True</property> | 4484 | <property name="visible">True</property> |
4485 | <property name="can_focus">False</property> | 4485 | <property name="can_focus">False</property> |
4486 | </object> | 4486 | </object> |
@@ -4589,24 +4589,6 @@ | |||
4589 | </object> | 4589 | </object> |
4590 | </child> | 4590 | </child> |
4591 | <child> | 4591 | <child> |
4592 | <object class="GtkTreeViewColumn" id="GNUNET_setup_gns_ispublic_treeviewcolumn"> | ||
4593 | <property name="sizing">fixed</property> | ||
4594 | <property name="fixed_width">50</property> | ||
4595 | <property name="title">Public</property> | ||
4596 | <property name="clickable">True</property> | ||
4597 | <child> | ||
4598 | <object class="GtkCellRendererToggle" id="GNUNET_setup_gns_ispublic_cellrenderertoggle"> | ||
4599 | <signal name="toggled" handler="GNUNET_setup_gns_ispublic_cellrenderertoggle_toggled_cb" swapped="no"/> | ||
4600 | </object> | ||
4601 | <attributes> | ||
4602 | <attribute name="sensitive">11</attribute> | ||
4603 | <attribute name="visible">11</attribute> | ||
4604 | <attribute name="active">1</attribute> | ||
4605 | </attributes> | ||
4606 | </child> | ||
4607 | </object> | ||
4608 | </child> | ||
4609 | <child> | ||
4610 | <object class="GtkTreeViewColumn" id="GNUNET_setup_gns_type_treeviewcolumn"> | 4592 | <object class="GtkTreeViewColumn" id="GNUNET_setup_gns_type_treeviewcolumn"> |
4611 | <property name="sizing">autosize</property> | 4593 | <property name="sizing">autosize</property> |
4612 | <property name="fixed_width">90</property> | 4594 | <property name="fixed_width">90</property> |
@@ -4630,6 +4612,27 @@ | |||
4630 | </object> | 4612 | </object> |
4631 | </child> | 4613 | </child> |
4632 | <child> | 4614 | <child> |
4615 | <object class="GtkTreeViewColumn" id="GNUNET_setup_gns_value_treeviewcolumn"> | ||
4616 | <property name="sizing">autosize</property> | ||
4617 | <property name="title">Value</property> | ||
4618 | <property name="expand">True</property> | ||
4619 | <property name="clickable">True</property> | ||
4620 | <property name="sort_column_id">7</property> | ||
4621 | <child> | ||
4622 | <object class="GtkCellRendererText" id="GNUNET_setup_gns_value_cellrenderertext"> | ||
4623 | <signal name="edited" handler="GNUNET_setup_gns_value_cellrenderertext_edited_cb" swapped="no"/> | ||
4624 | </object> | ||
4625 | <attributes> | ||
4626 | <attribute name="sensitive">11</attribute> | ||
4627 | <attribute name="visible">10</attribute> | ||
4628 | <attribute name="background">8</attribute> | ||
4629 | <attribute name="editable">11</attribute> | ||
4630 | <attribute name="text">7</attribute> | ||
4631 | </attributes> | ||
4632 | </child> | ||
4633 | </object> | ||
4634 | </child> | ||
4635 | <child> | ||
4633 | <object class="GtkTreeViewColumn" id="GNUNET_setup_gns_expiration_treeviewcolumn"> | 4636 | <object class="GtkTreeViewColumn" id="GNUNET_setup_gns_expiration_treeviewcolumn"> |
4634 | <property name="title">Expiration</property> | 4637 | <property name="title">Expiration</property> |
4635 | <property name="clickable">True</property> | 4638 | <property name="clickable">True</property> |
@@ -4651,22 +4654,19 @@ | |||
4651 | </object> | 4654 | </object> |
4652 | </child> | 4655 | </child> |
4653 | <child> | 4656 | <child> |
4654 | <object class="GtkTreeViewColumn" id="GNUNET_setup_gns_value_treeviewcolumn"> | 4657 | <object class="GtkTreeViewColumn" id="GNUNET_setup_gns_ispublic_treeviewcolumn"> |
4655 | <property name="sizing">autosize</property> | 4658 | <property name="sizing">fixed</property> |
4656 | <property name="title">Value</property> | 4659 | <property name="fixed_width">50</property> |
4657 | <property name="expand">True</property> | 4660 | <property name="title">Public</property> |
4658 | <property name="clickable">True</property> | 4661 | <property name="clickable">True</property> |
4659 | <property name="sort_column_id">7</property> | ||
4660 | <child> | 4662 | <child> |
4661 | <object class="GtkCellRendererText" id="GNUNET_setup_gns_value_cellrenderertext"> | 4663 | <object class="GtkCellRendererToggle" id="GNUNET_setup_gns_ispublic_cellrenderertoggle"> |
4662 | <signal name="edited" handler="GNUNET_setup_gns_value_cellrenderertext_edited_cb" swapped="no"/> | 4664 | <signal name="toggled" handler="GNUNET_setup_gns_ispublic_cellrenderertoggle_toggled_cb" swapped="no"/> |
4663 | </object> | 4665 | </object> |
4664 | <attributes> | 4666 | <attributes> |
4665 | <attribute name="sensitive">11</attribute> | 4667 | <attribute name="sensitive">11</attribute> |
4666 | <attribute name="visible">10</attribute> | 4668 | <attribute name="visible">11</attribute> |
4667 | <attribute name="background">8</attribute> | 4669 | <attribute name="active">1</attribute> |
4668 | <attribute name="editable">11</attribute> | ||
4669 | <attribute name="text">7</attribute> | ||
4670 | </attributes> | 4670 | </attributes> |
4671 | </child> | 4671 | </child> |
4672 | </object> | 4672 | </object> |
diff --git a/contrib/qr_dummy.png b/contrib/qr_dummy.png new file mode 100644 index 00000000..9c0ffb33 --- /dev/null +++ b/contrib/qr_dummy.png | |||
Binary files differ | |||
diff --git a/src/setup/Makefile.am b/src/setup/Makefile.am index 6d483df4..f9d22496 100644 --- a/src/setup/Makefile.am +++ b/src/setup/Makefile.am | |||
@@ -34,7 +34,7 @@ gnunet_setup_SOURCES = \ | |||
34 | gnunet-setup-hostlist-server.c | 34 | gnunet-setup-hostlist-server.c |
35 | gnunet_setup_LDADD = \ | 35 | gnunet_setup_LDADD = \ |
36 | $(top_builddir)/src/lib/libgnunetgtk.la \ | 36 | $(top_builddir)/src/lib/libgnunetgtk.la \ |
37 | @GTK_LIBS@ @GNUNET_LIBS@ @GLADE_LIBS@ \ | 37 | @GTK_LIBS@ @GNUNET_LIBS@ @GLADE_LIBS@ @QR_CFLAGS@ @QR_LIBS@ \ |
38 | $(WINLIBS) \ | 38 | $(WINLIBS) \ |
39 | -lgnunetutil -lgnunetnat -lgnunetnamestore \ | 39 | -lgnunetutil -lgnunetnat -lgnunetnamestore \ |
40 | $(INTLLIBS) | 40 | $(INTLLIBS) |
diff --git a/src/setup/gnunet-setup-gns.c b/src/setup/gnunet-setup-gns.c index 78aa3a0c..12399cb8 100644 --- a/src/setup/gnunet-setup-gns.c +++ b/src/setup/gnunet-setup-gns.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <gnunet/gnunet_namestore_service.h> | 28 | #include <gnunet/gnunet_namestore_service.h> |
29 | #include <gnunet/gnunet_dnsparser_lib.h> | 29 | #include <gnunet/gnunet_dnsparser_lib.h> |
30 | 30 | ||
31 | |||
32 | /** | 31 | /** |
33 | * Text we use for the 'name' entry for the user to select | 32 | * Text we use for the 'name' entry for the user to select |
34 | * for creating a new name. | 33 | * for creating a new name. |
@@ -61,7 +60,10 @@ | |||
61 | */ | 60 | */ |
62 | #define PSEU_EMPTY_STR gettext_noop ("<not set>") | 61 | #define PSEU_EMPTY_STR gettext_noop ("<not set>") |
63 | 62 | ||
64 | 63 | /** | |
64 | * Height and width of the QR code | ||
65 | */ | ||
66 | #define QRCODE_IMAGE_SIZE 64 | ||
65 | 67 | ||
66 | /** | 68 | /** |
67 | * Columns in the gns model. | 69 | * Columns in the gns model. |
@@ -1542,6 +1544,104 @@ GNUNET_setup_gns_public_key_copy_button_clicked_cb (GtkButton *button, | |||
1542 | } | 1544 | } |
1543 | 1545 | ||
1544 | 1546 | ||
1547 | #if HAVE_QRENCODE_H | ||
1548 | #include <qrencode.h> | ||
1549 | #include <gdk-pixbuf/gdk-pixbuf.h> | ||
1550 | |||
1551 | /** | ||
1552 | * Create the QR code image for our zone. | ||
1553 | */ | ||
1554 | static void | ||
1555 | setup_qrcode () | ||
1556 | { | ||
1557 | QRinput * qri; | ||
1558 | QRcode *qrc; | ||
1559 | char *str; | ||
1560 | const gchar * pseu; | ||
1561 | GtkEntry * entry; | ||
1562 | GdkPixbuf *pb; | ||
1563 | GtkImage *image; | ||
1564 | unsigned int x; | ||
1565 | unsigned int y; | ||
1566 | unsigned int off; | ||
1567 | guchar *pixels; | ||
1568 | int n_channels; | ||
1569 | int c; | ||
1570 | const char *dir; | ||
1571 | char *fn; | ||
1572 | |||
1573 | qri = QRinput_new2 (0, QR_ECLEVEL_Q); | ||
1574 | if (NULL == qri) | ||
1575 | { | ||
1576 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "QRinput_new2"); | ||
1577 | return; | ||
1578 | } | ||
1579 | entry = GTK_ENTRY (GNUNET_SETUP_get_object ("GNUNET_setup_gns_pseu_entry")); | ||
1580 | pseu = gtk_entry_get_text (GTK_ENTRY(entry)); | ||
1581 | GNUNET_asprintf (&str, | ||
1582 | "gnunet://gns/%s/%s\n", | ||
1583 | zone_as_string, | ||
1584 | pseu); | ||
1585 | if (0 != QRinput_append (qri, | ||
1586 | QR_MODE_8, | ||
1587 | strlen (str), | ||
1588 | (unsigned char*) str)) | ||
1589 | { | ||
1590 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "QRinput_append"); | ||
1591 | GNUNET_free (str); | ||
1592 | return; | ||
1593 | } | ||
1594 | GNUNET_free (str); | ||
1595 | qrc = QRcode_encodeInput (qri); | ||
1596 | if (NULL == qrc) | ||
1597 | { | ||
1598 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "QRcode_encodeInput"); | ||
1599 | QRinput_free (qri); | ||
1600 | return; | ||
1601 | } | ||
1602 | /* We use a trick to create a pixbuf in a way that works for both Gtk2 and Gtk3 | ||
1603 | by loading a dummy file from disk; all other methods are not portable to both | ||
1604 | Gtk2 and Gtk3. */ | ||
1605 | dir = GNUNET_GTK_get_data_dir (); | ||
1606 | GNUNET_asprintf (&fn, | ||
1607 | "%s%s", | ||
1608 | dir, | ||
1609 | "qr_dummy.png"); | ||
1610 | pb = gdk_pixbuf_new_from_file_at_size (fn, | ||
1611 | QRCODE_IMAGE_SIZE, QRCODE_IMAGE_SIZE, | ||
1612 | NULL); | ||
1613 | GNUNET_free (fn); | ||
1614 | if (NULL == pb) | ||
1615 | { | ||
1616 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Failed to initialize QR-code pixbuf")); | ||
1617 | QRinput_free (qri); | ||
1618 | return; | ||
1619 | } | ||
1620 | pixels = gdk_pixbuf_get_pixels (pb); | ||
1621 | n_channels = gdk_pixbuf_get_n_channels (pb); | ||
1622 | for (x=0;x<QRCODE_IMAGE_SIZE;x++) | ||
1623 | for (y=0;y<QRCODE_IMAGE_SIZE;y++) | ||
1624 | { | ||
1625 | off = (x * qrc->width / QRCODE_IMAGE_SIZE) + | ||
1626 | (y * qrc->width / QRCODE_IMAGE_SIZE) * qrc->width; | ||
1627 | for (c = 0; c < n_channels; c++) | ||
1628 | pixels[(y * QRCODE_IMAGE_SIZE + x) * n_channels + c] = (0 == (qrc->data[off] & 1)) ? 0 : 0xFF; | ||
1629 | } | ||
1630 | image = GTK_IMAGE (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_image")); | ||
1631 | if (NULL == image) | ||
1632 | { | ||
1633 | GNUNET_break (0); | ||
1634 | QRcode_free (qrc); | ||
1635 | QRinput_free (qri); | ||
1636 | return; | ||
1637 | } | ||
1638 | gtk_image_set_from_pixbuf (image, pb); | ||
1639 | QRcode_free (qrc); | ||
1640 | QRinput_free (qri); | ||
1641 | } | ||
1642 | #endif | ||
1643 | |||
1644 | |||
1545 | /** | 1645 | /** |
1546 | * Connect to the namestore and initialize the main | 1646 | * Connect to the namestore and initialize the main |
1547 | * GNS tree view. | 1647 | * GNS tree view. |
@@ -1615,6 +1715,13 @@ GNUNET_SETUP_gns_init () | |||
1615 | tv = GTK_TREE_VIEW (GNUNET_SETUP_get_object ("GNUNET_setup_gns_main_treeview")); | 1715 | tv = GTK_TREE_VIEW (GNUNET_SETUP_get_object ("GNUNET_setup_gns_main_treeview")); |
1616 | tm = GTK_TREE_MODEL(ts); | 1716 | tm = GTK_TREE_MODEL(ts); |
1617 | zone_as_string = GNUNET_strdup ((char *) &shenc); | 1717 | zone_as_string = GNUNET_strdup ((char *) &shenc); |
1718 | #if HAVE_QRENCODE_H | ||
1719 | setup_qrcode (); | ||
1720 | #else | ||
1721 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_image"))); | ||
1722 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_saveas_button"))); | ||
1723 | gtk_widget_hide (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_gns_qr_vseparator"))); | ||
1724 | #endif | ||
1618 | label = g_markup_printf_escaped (_("<b>Editing zone %s</b>"), | 1725 | label = g_markup_printf_escaped (_("<b>Editing zone %s</b>"), |
1619 | zone_as_string); | 1726 | zone_as_string); |
1620 | gtk_label_set_markup (GTK_LABEL (GNUNET_SETUP_get_object ("GNUNET_setup_gns_zone_label")), | 1727 | gtk_label_set_markup (GTK_LABEL (GNUNET_SETUP_get_object ("GNUNET_setup_gns_zone_label")), |
@@ -1622,7 +1729,6 @@ GNUNET_SETUP_gns_init () | |||
1622 | g_free (label); | 1729 | g_free (label); |
1623 | 1730 | ||
1624 | /* Load zone from namestore! */ | 1731 | /* Load zone from namestore! */ |
1625 | |||
1626 | /* Append a top level row and leave it empty */ | 1732 | /* Append a top level row and leave it empty */ |
1627 | gtk_tree_store_insert_with_values (ts, &toplevel, NULL, 0, | 1733 | gtk_tree_store_insert_with_values (ts, &toplevel, NULL, 0, |
1628 | GNS_TREESTORE_COL_NAME, _(NEW_NAME_STR), | 1734 | GNS_TREESTORE_COL_NAME, _(NEW_NAME_STR), |