[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-mdb] 57/93: stick to convention
From: |
gnunet |
Subject: |
[taler-taler-mdb] 57/93: stick to convention |
Date: |
Mon, 18 Nov 2019 21:13:20 +0100 |
This is an automated email from the git hooks/post-receive script.
marco-boss pushed a commit to branch master
in repository taler-mdb.
commit 82126b9d0c1b640bd59a21dfa97677ded686fd4d
Author: Boss Marco <address@hidden>
AuthorDate: Fri Nov 15 21:58:32 2019 +0100
stick to convention
---
src/main.c | 176 +++++++++++++++++++++++++++++++++++--------------------------
1 file changed, 100 insertions(+), 76 deletions(-)
diff --git a/src/main.c b/src/main.c
index ce9a569..eee37bd 100644
--- a/src/main.c
+++ b/src/main.c
@@ -106,15 +106,17 @@ static const uint8_t get_data[] = { 0x00, 0xCA, 0x01,
0x00, 0x00, 0x00 };
struct Product
{
struct TALER_Amount price;
+
char *description;
+
char *number;
+
char key;
};
struct PaymentActivity
{
-
struct TALER_MERCHANT_ProposalOperation *po;
struct TALER_MERCHANT_CheckPaymentOperation *cpo;
@@ -193,65 +195,14 @@ show_qrcode (const char *uri)
uint8_t *pixels;
unsigned int size;
char *upper;
+ size_t xOff;
+ size_t yOff;
+ size_t width = qrDisplay.var_info.xres;
+ size_t height = qrDisplay.var_info.yres;
const unsigned int scale = 8;
const unsigned int n_channels = 3;
- /* open the framebuffer device */
- qrDisplay.devicefd = open (FRAMEBUFFER_DEVICE,
- O_RDWR);
- if (0 > qrDisplay.devicefd)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "open(), could not open framebuffer device %s",
- FRAMEBUFFER_DEVICE);
- return;
- }
-
- /* read information about the screen */
- ioctl (qrDisplay.devicefd,
- FBIOGET_VSCREENINFO,
- &qrDisplay.var_info);
-
- /* store current screeninfo for reset */
- memcpy (&qrDisplay.orig_vinfo,
- &qrDisplay.var_info,
- sizeof(struct fb_var_screeninfo));
-
- if (qrDisplay.var_info.bits_per_pixel != 8)
- {
- /* Change variable info to 8bit per pixel */
- qrDisplay.var_info.bits_per_pixel = 8;
- if (0 > ioctl (qrDisplay.devicefd,
- FBIOPUT_VSCREENINFO,
- &qrDisplay.var_info))
- {
- printf ("Error setting variable information.\n");
- return;
- }
- }
-
- /* Get fixed screen information */
- if (0 > ioctl (qrDisplay.devicefd,
- FBIOGET_FSCREENINFO,
- &qrDisplay.fix_info))
- {
- printf ("Error reading fixed information.\n");
- return;
- }
-
- /* get pointer onto frame buffer */
- qrDisplay.memory = (uint8_t *) mmap (NULL,
- qrDisplay.fix_info.smem_len,
- PROT_READ | PROT_WRITE, MAP_SHARED,
- qrDisplay.devicefd,
- 0);
- if (0 > qrDisplay.devicefd)
- {
- printf ("failed to map display memory\n");
- return;
- }
-
qri = QRinput_new2 (0, QR_ECLEVEL_M);
if (NULL == qri)
{
@@ -307,10 +258,8 @@ show_qrcode (const char *uri)
QRinput_free (qri);
/* show the qrcode */
- size_t width = qrDisplay.var_info.xres;
- size_t height = qrDisplay.var_info.yres;
- int xOff = (height - size) / 2;
- int yOff = (width - size) / 2;
+ xOff = (height - size) / 2;
+ yOff = (width - size) / 2;
for (size_t row = xOff; row < height; row++)
{
for (size_t col = yOff; col < width; col++)
@@ -326,20 +275,6 @@ show_qrcode (const char *uri)
}
}
- /* free the data */
- munmap (qrDisplay.memory,
- qrDisplay.fix_info.smem_len);
- /* reset original state */
- if (0 > ioctl (qrDisplay.devicefd,
- FBIOPUT_VSCREENINFO,
- &qrDisplay.orig_vinfo))
- {
- printf ("Error re-setting variable information.\n");
- }
-
- /* close device */
- close (qrDisplay.devicefd);
-
GNUNET_free (pixels);
}
@@ -381,10 +316,23 @@ cleanup_payment (struct PaymentActivity *pa)
GNUNET_SCHEDULER_cancel (pa->task);
if (NULL != pa->delay_task)
GNUNET_SCHEDULER_cancel (pa->delay_task);
- /* FIXME - cont. also abort when nfc device gets disconnected (maybe this is
ok? because nfc is mandatory) */
GNUNET_free_non_null (pa->taler_pay_uri);
GNUNET_free_non_null (pa->order_id);
GNUNET_free (pa);
+
+#if HAVE_QRENCODE_H
+ if (NULL != qrDisplay.memory)
+ {
+ for (size_t row = 0; row < qrDisplay.var_info.yres; row++)
+ {
+ for (size_t col = 0; col < qrDisplay.var_info.xres; col++)
+ {
+ qrDisplay.memory[(row * qrDisplay.var_info.yres + col)] = 0xFF;
+ }
+ }
+ }
+ /* FIXME: dimm background light of display */
+#endif
}
@@ -421,6 +369,23 @@ shutdown_task (void *cls)
GNUNET_CURL_gnunet_rc_destroy (rc);
rc = NULL;
}
+ if (NULL != qrDisplay.memory)
+ {
+ /* free the display data */
+ munmap (qrDisplay.memory,
+ qrDisplay.fix_info.smem_len);
+ /* reset original state */
+ if (0 > ioctl (qrDisplay.devicefd,
+ FBIOPUT_VSCREENINFO,
+ &qrDisplay.orig_vinfo))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "failed to reset originial display state\n");
+ }
+
+ /* close device */
+ close (qrDisplay.devicefd);
+ }
if (NULL != products)
{
for (unsigned int i = 0; i < products_length; i++)
@@ -689,7 +654,6 @@ check_payment_cb (void *cls,
{
fprintf (stderr,
"FIXME: yield product here!\n");
- /* FIXME: hide QR code here! */
/* FIXME: later: continue to offer Internet UNTIL
NFC device disconnects (if NFC connected) */
cleanup_payment (pa);
@@ -1089,6 +1053,66 @@ run (void *cls,
GNUNET_assert (GNUNET_OK ==
GNUNET_CURL_append_header (ctx,
authorization));
+#if HAVE_QRENCODE_H
+ /* open the framebuffer device */
+ qrDisplay.devicefd = open (FRAMEBUFFER_DEVICE,
+ O_RDWR);
+ if (0 > qrDisplay.devicefd)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "open(), could not open framebuffer device %s",
+ FRAMEBUFFER_DEVICE);
+ return;
+ }
+
+ /* read information about the screen */
+ ioctl (qrDisplay.devicefd,
+ FBIOGET_VSCREENINFO,
+ &qrDisplay.var_info);
+
+ /* store current screeninfo for reset */
+ memcpy (&qrDisplay.orig_vinfo,
+ &qrDisplay.var_info,
+ sizeof(struct fb_var_screeninfo));
+
+ if (8 != qrDisplay.var_info.bits_per_pixel)
+ {
+ /* Change variable info to 8bit per pixel */
+ qrDisplay.var_info.bits_per_pixel = 8;
+ if (0 > ioctl (qrDisplay.devicefd,
+ FBIOPUT_VSCREENINFO,
+ &qrDisplay.var_info))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Error setting display bpp to 8\n");
+ return;
+ }
+ }
+
+ /* Get fixed screen information */
+ if (0 > ioctl (qrDisplay.devicefd,
+ FBIOGET_FSCREENINFO,
+ &qrDisplay.fix_info))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Error reading fixed display information\n");
+ return;
+ }
+
+ /* get pointer onto frame buffer */
+ qrDisplay.memory = (uint8_t *) mmap (NULL,
+ qrDisplay.fix_info.smem_len,
+ PROT_READ | PROT_WRITE, MAP_SHARED,
+ qrDisplay.devicefd,
+ 0);
+ if (0 > qrDisplay.devicefd)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "failed to map display memory\n");
+ return;
+ }
+#endif
+
start_read_keyboard ();
}
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [taler-taler-mdb] 55/93: better solution, still bugs, (continued)
- [taler-taler-mdb] 55/93: better solution, still bugs, gnunet, 2019/11/18
- [taler-taler-mdb] 53/93: bug detected, see README, gnunet, 2019/11/18
- [taler-taler-mdb] 60/93: fix, gnunet, 2019/11/18
- [taler-taler-mdb] 56/93: no bugs with uint8_t, but display is divided in 4 pieces, gnunet, 2019/11/18
- [taler-taler-mdb] 61/93: qr gen, gnunet, 2019/11/18
- [taler-taler-mdb] 59/93: when no display, show on stdout, gnunet, 2019/11/18
- [taler-taler-mdb] 54/93: first (half working) qrcode, gnunet, 2019/11/18
- [taler-taler-mdb] 52/93: stop NFC interaction after payment succeeded, gnunet, 2019/11/18
- [taler-taler-mdb] 58/93: fix, gnunet, 2019/11/18
- [taler-taler-mdb] 65/93: qr gen, gnunet, 2019/11/18
- [taler-taler-mdb] 57/93: stick to convention,
gnunet <=
- [taler-taler-mdb] 49/93: intermediary commit, gnunet, 2019/11/18
- [taler-taler-mdb] 62/93: qr gen, gnunet, 2019/11/18
- [taler-taler-mdb] 47/93: Merge branch 'refactor' of https://git.taler.net/taler-mdb into refactor, gnunet, 2019/11/18
- [taler-taler-mdb] 50/93: slight logic clean up, gnunet, 2019/11/18
- [taler-taler-mdb] 51/93: fix json construction, gnunet, 2019/11/18
- [taler-taler-mdb] 63/93: qr gen, gnunet, 2019/11/18
- [taler-taler-mdb] 66/93: swap xy, gnunet, 2019/11/18
- [taler-taler-mdb] 68/93: see stuff, gnunet, 2019/11/18
- [taler-taler-mdb] 82/93: see stuff, gnunet, 2019/11/18
- [taler-taler-mdb] 72/93: see stuff, gnunet, 2019/11/18