[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-mdb] 29/93: dce
From: |
gnunet |
Subject: |
[taler-taler-mdb] 29/93: dce |
Date: |
Mon, 18 Nov 2019 21:12:52 +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 5ed8feaf2ecba28d88f3e746bf3f5e79782306bf
Author: Christian Grothoff <address@hidden>
AuthorDate: Sat Nov 9 16:09:56 2019 +0100
dce
---
src/communication.c | 126 ----------------------------------------------------
src/communication.h | 52 ----------------------
src/configuration.h | 62 --------------------------
src/nfc.c | 32 -------------
src/nfc.h | 33 --------------
src/product.c | 101 -----------------------------------------
src/product.h | 77 --------------------------------
src/wallet.c | 107 --------------------------------------------
src/wallet.h | 51 ---------------------
9 files changed, 641 deletions(-)
diff --git a/src/communication.c b/src/communication.c
deleted file mode 100644
index b9110db..0000000
--- a/src/communication.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2019 GNUnet e.V.
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more
-details.
-
- You should have received a copy of the GNU General Public License
-along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-*/
-
-/**
-* @file communication.c
-* @brief functions to communicate with taler backend
-* @author BOSS Marco
-*/
-
-#include <string.h>
-#include <stdbool.h>
-#include <jansson.h>
-#include <gnunet/platform.h>
-#include <gnunet/gnunet_util_lib.h>
-
-#include "communication.h"
-#include "wallet.h"
-#include "configuration.h"
-
-
-int SNACK_taler_check_payment_status (CURL *curl, ProductOrder *product)
-{
- CURLcode result;
- struct curl_slist *list = NULL;
-
- /* reset the response size */
- product->response->size = 0;
-
- /* set the url */
- curl_easy_setopt (curl, CURLOPT_URL, product->checkUrl);
-
- /* set the authentication headers */
- list = curl_slist_append (list, product->talerCfg->authorization);
- curl_easy_setopt (curl, CURLOPT_HTTPHEADER, list);
-
- /* curl option "get" */
- curl_easy_setopt (curl, CURLOPT_HTTPGET, true);
-
- /* pass the write function and the struct to write to */
- curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, _SNACK_taler_write_response);
- curl_easy_setopt (curl, CURLOPT_WRITEDATA, (void *) product->response);
-
- /* perform the call */
- result = curl_easy_perform (curl);
- if ( result != CURLE_OK )
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "SNACK_taler_check_payment_status: could not communicate with
\"%s\"\n",
- product->checkUrl);
- curl_slist_free_all (list);
- return EXIT_FAILURE;
- }
-
- /* reset the curl options */
- curl_easy_reset (curl);
-
- /* clean up */
- curl_slist_free_all (list);
-
-
- printf ("%s\n", product->response->string);
-
- return EXIT_SUCCESS;
-}
-
-int SNACK_taler_parse_json (const TalerResponse *response, const
- char *memberName,
- char **returnStr)
-{
- /* json variables */
- json_error_t error;
- json_t *root = NULL;
-
- /* if the provided string was not allocated before allocate initial size 1 to
- * realloc later */
- if ( ! (*returnStr) )
- returnStr = GNUNET_malloc (1);
-
- /* load the json with th string provided from taler in the response struct */
- root = json_loads (response->string, JSON_DISABLE_EOF_CHECK, &error);
- if ( ! root )
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "SNACK_taler_parse_json: %s\n",
- error.text);
- return EXIT_FAILURE;
- }
- char *result = NULL;
- if ( json_unpack (root, "{s:s}", memberName, &result) < 0 )
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "SNACK_taler_parse_json: no member named \"%s\" found!\n",
- memberName);
- json_decref (root);
- return EXIT_FAILURE;
- }
- if ( ! result )
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "SNACK_taler_parse_json: no member named \"%s\" found!\n",
- memberName);
- json_decref (root);
- return EXIT_FAILURE;
- }
-
- *returnStr = GNUNET_realloc (*returnStr, strlen (result) + 1);
- strcpy (*returnStr, result);
-
- json_decref (root);
- return EXIT_SUCCESS;
-}
diff --git a/src/communication.h b/src/communication.h
deleted file mode 100644
index e730aef..0000000
--- a/src/communication.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2019 GNUnet e.V.
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more
-details.
-
- You should have received a copy of the GNU General Public License
-along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-*/
-
-/**
-* @file communication.h
-* @brief functions to communicate with taler backend
-* @author BOSS Marco
-*/
-
-
-#ifndef COMM_H
-#define COMM_H
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdbool.h>
-#include <curl/curl.h>
-
-#include "product.h"
-
-int SNACK_taler_init (CURL **curl);
-
-void SNACK_taler_exit (CURL **curl);
-
-int SNACK_taler_create_order_req (ProductOrder *product);
-
-int SNACK_taler_create_order (CURL *curl, ProductOrder *product);
-
-int SNACK_taler_check_payment_status (CURL *curl, ProductOrder *product);
-
-int SNACK_taler_parse_json (const TalerResponse *response, const
- char *memberName,
- char **returnStr);
-
-
-#endif // COMM_H
diff --git a/src/configuration.h b/src/configuration.h
deleted file mode 100644
index 86eb7e5..0000000
--- a/src/configuration.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2019 GNUnet e.V.
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more
-details.
-
- You should have received a copy of the GNU General Public License
-along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-*/
-
-/**
-* @file configuration.h
-* @brief in this file you can set your url specifications needed to
comminicate with taler
-* @author BOSS Marco
-*/
-
-#ifndef URL_H
-#define URL_H
-
-#include <stdio.h>
-#include <inttypes.h>
-#include <gnunet/platform.h>
-#include <gnunet/gnunet_util_lib.h>
-
-/* config sections */
-#define TALER "taler"
-#define BACKOFFICE "backoffice"
-
-/* config keys */
-#define CURRENCY "currency"
-#define AUTHORIZATION "authorization"
-#define BACKEND_BASE_URL "backend-base-url"
-#define FULLFILLMENT_URL "fulfillment-url"
-#define FULLFILLMENT_MSG "fulfillment-msg"
-
-
-/* taler url extensions */
-#define SNACK_TALER_ORDER "/order"
-#define SNACK_TALER_CHECK "/check-payment"
-#define SNACK_TALER_ORDER_CHECK "?order_id="
-
-
-/* json order check keys */
-#define SNACK_JSON_PAID "paid"
-#define SNACK_JSON_PAY_URI "taler_pay_uri"
-#define SNACK_JSON_ORDER_ID "order_id"
-
-
-/* nonce definitions */
-#define NONCE_SIZE 32
-
-
-#endif // URL_H
diff --git a/src/nfc.c b/src/nfc.c
deleted file mode 100644
index 3c692b1..0000000
--- a/src/nfc.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2019 GNUnet e.V.
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more
-details.
-
- You should have received a copy of the GNU General Public License
-along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-*/
-
-/**
-* @file nfc.c
-* @brief functions used to comunicate over nfc interface
-* @author BOSS Marco
-*/
-
-#include <string.h>
-#include <unistd.h>
-#include <gnunet/platform.h>
-#include <gnunet/gnunet_util_lib.h>
-
-#include "nfc.h"
-#include "wallet.h"
diff --git a/src/nfc.h b/src/nfc.h
deleted file mode 100644
index 62268ff..0000000
--- a/src/nfc.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2019 GNUnet e.V.
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more
-details.
-
- You should have received a copy of the GNU General Public License
-along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-*/
-
-/**
-* @file nfc.h
-* @brief functions used to comunicate over nfc interface
-* @author BOSS Marco
-*/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <nfc/nfc.h>
-
-int SNACK_nfc_transmit (nfc_context *context, const char *talerPayUrl, size_t
- urlSize);
-
-int SNACK_nfc_connect_target (nfc_device *pnd, nfc_target *nt);
diff --git a/src/product.c b/src/product.c
deleted file mode 100644
index 99fb583..0000000
--- a/src/product.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2019 GNUnet e.V.
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more
-details.
-
- You should have received a copy of the GNU General Public License
-along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-*/
-
-/**
-* @file product.c
-* @brief defined a product order with the attributes of the product and
-the links used to communicate with taler. Provides setter methods to set
-the attributes.
-* @author BOSS Marco
-*/
-
-#include <string.h>
-#include <jansson.h>
-
-#include "product.h"
-#include "configuration.h"
-#include "communication.h"
-
-
-
-int SNACK_product_set_check_url (ProductOrder *product)
-{
- product->checkUrl = GNUNET_realloc (product->checkUrl,
- strlen
(product->talerCfg->backendBaseUrl)
- + strlen (SNACK_TALER_CHECK)
- + strlen (SNACK_TALER_ORDER_CHECK)
- + strlen (product->orderID) + 1);
-
- sprintf (product->checkUrl, "%s%s%s%s", product->talerCfg->backendBaseUrl,
- SNACK_TALER_CHECK, SNACK_TALER_ORDER_CHECK,
- product->orderID);
- printf ("Url to check payment: %s\n\n", product->checkUrl);
-
- return EXIT_SUCCESS;
-}
-
-
-int SNACK_product_set_pay_url (ProductOrder *product)
-{
- return SNACK_taler_parse_json (product->response, SNACK_JSON_PAY_URI,
- &(product->payUrl));
-}
-
-int SNACK_product_set_paid_status (ProductOrder *product)
-{
- json_error_t error;
- json_t *root = NULL;
-
- /* variable to extract the boolean value out of json object */
- int b = -1;
-
- root = json_loads (product->response->string, JSON_DISABLE_EOF_CHECK,
&error);
- if ( ! root )
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "SNACK_taler_parse_json: %s\n",
- error.text);
- return EXIT_FAILURE;
- }
-
- /* extract the boolean value of paid out of the json object */
- if ( json_unpack (root, "{s:b}", SNACK_JSON_PAID, &b) < 0 )
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "SNACK_taler_parse_json: no value \"%s\" found!\n",
- SNACK_JSON_PAID);
- json_decref (root);
- return EXIT_FAILURE;
- }
-
- json_decref (root);
-
- /* set the paid status to true or false */
- if ((b == true)||(b == false))
- {
- product->paid = b;
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "SNACK_product_set_paid_status: json parsing failed\n");
- return EXIT_FAILURE;
- }
-
- return EXIT_SUCCESS;
-}
diff --git a/src/product.h b/src/product.h
deleted file mode 100644
index 7605cf6..0000000
--- a/src/product.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2019 GNUnet e.V.
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more
-details.
-
- You should have received a copy of the GNU General Public License
-along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-*/
-
-/**
-* @file product.h
-* @brief defined a product order with the attributes of the product and
-the links used to communicate with taler. Provides setter methods to set
-the attributes.
-* @author BOSS Marco
-*/
-
-#ifndef PRODUCT_H
-#define PRODUCT_H
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <gnunet/platform.h>
-#include <gnunet/gnunet_util_lib.h>
-
-typedef struct TalerResponse
-{
- char *string;
- size_t size;
-} TalerResponse;
-
-typedef struct ProductOrder
-{
- char *product;
- char *amount;
- char *nonce;
- char *orderID;
- char *checkUrl;
- char *payUrl;
- char *orderRequest;
- bool paid;
- TalerResponse *response;
-} ProductOrder;
-
-
-int SNACK_product_init (ProductOrder *product, struct
- GNUNET_CONFIGURATION_Handle *cfg);
-
-void SNACK_product_exit (ProductOrder *product);
-
-void SNACK_product_reset (ProductOrder *product);
-
-int SNACK_product_set_check_url (ProductOrder *product);
-
-int SNACK_product_set_order_id (ProductOrder *product);
-
-int SNACK_product_set_pay_url (ProductOrder *product);
-
-int SNACK_product_set_paid_status (ProductOrder *product);
-
-int SNACK_product_set_cfg_value (struct GNUNET_CONFIGURATION_Handle *cfg, const
- char *section, const char *key, char **value);
-
-void SNACK_product_generate_nonce (char **nonce, size_t size);
-
-#endif // PRODUCT_H
diff --git a/src/wallet.c b/src/wallet.c
deleted file mode 100644
index 1d7e8da..0000000
--- a/src/wallet.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2019 GNUnet e.V.
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more
-details.
-
- You should have received a copy of the GNU General Public License
-along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-*/
-
-/**
-* @file wallet.c
-* @brief functions to communicate with taler wallet over nfc
-* @author BOSS Marco
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <jansson.h>
-#include <unistd.h>
-#include <gnunet/platform.h>
-#include <gnunet/gnunet_util_lib.h>
-
-#include "wallet.h"
-#include "configuration.h"
-
-int SNACK_wallet_select_aid (nfc_device *pnd)
-{
-}
-
-int SNACK_put_message (nfc_device *pnd, const char *msg, size_t msgSize)
-{
-
- return SNACK_check_response (response, sizeof(response) );
-}
-
-int SNACK_wallet_tunneling (nfc_device *pnd, const char *msg, size_t msgSize)
-{
- uint8_t response[255] = {0x00};
-
- printf ("checking for tunneling request\n");
-
- if ( nfc_initiator_transceive_bytes (pnd, get_data, sizeof(get_data),
- response,
- sizeof(response), TRANSMIT_TIMEOUT) < 0
)
-
- {
- printf ("wallet_put_message: Failed to put message\n");
- return EXIT_FAILURE;
- }
-
- for ( uint8_t i = 0; i < 255; ++i ) {
- printf ("%.2x ", response[i]);
- }
- printf ("\n");
-
- return SNACK_check_response (response, sizeof(response) );
-
-}
-
-
-int SNACK_check_response (uint8_t *response, uint8_t responseLen)
-{
- if ( strcmp ((char *) response, APDU_SUCCESS) == 0 )
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Transmission success\n");
- }
- else {
- SNACK_print_hex_info (
- "Transmission failure, return code: ", response,
- responseLen);
- return EXIT_FAILURE;
- }
-
- return EXIT_SUCCESS;
-}
-
-int SNACK_concat_message (const uint8_t*command, size_t commandSize, const
- uint8_t*message, uint8_t *retMsg, size_t returnSize)
-{
- if ( ! command || ! message )
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "SNACK_concat_message: command and message can't be null");
- return EXIT_FAILURE;
- }
-
- uint8_t i = 0;
- for (; i < commandSize; ++i ) {
- retMsg[i] = command[i];
- }
- for (; i < returnSize; ++i) {
- retMsg[i] = message[i - commandSize];
- }
-
- return EXIT_SUCCESS;
-}
diff --git a/src/wallet.h b/src/wallet.h
deleted file mode 100644
index e6438ea..0000000
--- a/src/wallet.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2019 GNUnet e.V.
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more
-details.
-
- You should have received a copy of the GNU General Public License
-along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-*/
-
-/**
-* @file wallet.h
-* @brief functions to communicate with taler wallet over nfc
-* @author BOSS Marco
-*/
-
-#ifndef WALLET_H
-#define WALLET_H
-
-#include <nfc/nfc.h>
-
-
-#define TRANSMIT_TIMEOUT 500
-
-
-int SNACK_wallet_select_aid (nfc_device *pnd);
-
-int SNACK_wallet_put_message (nfc_device *pnd, const char *msg, size_t
msgSize);
-
-int SNACK_wallet_tunneling (nfc_device *pnd, const char *msg, size_t msgSize);
-
-int SNACK_wallet_transmit (nfc_device*pnd, const char *msg, size_t msgLen);
-
-int SNACK_concat_message (const uint8_t*command, size_t commandSize, const
- uint8_t *message, uint8_t *retMsg, size_t
returnSize);
-
-int SNACK_check_response (uint8_t *response, uint8_t responseLen);
-
-void SNACK_print_hex_info (const char*message, const uint8_t *hexArray, size_t
- sizeHex);
-
-#endif // WALLET_H
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [taler-taler-mdb] 35/93: explicitly detect not-found code, (continued)
- [taler-taler-mdb] 35/93: explicitly detect not-found code, gnunet, 2019/11/18
- [taler-taler-mdb] 39/93: use test for now, gnunet, 2019/11/18
- [taler-taler-mdb] 38/93: merged, gnunet, 2019/11/18
- [taler-taler-mdb] 37/93: fixed delay when cancelling, new bugs detected marked with FIXME, gnunet, 2019/11/18
- [taler-taler-mdb] 34/93: fix, gnunet, 2019/11/18
- [taler-taler-mdb] 42/93: print URI sent to wallet for diagnostics, gnunet, 2019/11/18
- [taler-taler-mdb] 18/93: GNUnet logs added, -h option added, gnunet, 2019/11/18
- [taler-taler-mdb] 27/93: fixes, gnunet, 2019/11/18
- [taler-taler-mdb] 41/93: this was fixed, gnunet, 2019/11/18
- [taler-taler-mdb] 44/93: prepare logic for generation of QR codes, gnunet, 2019/11/18
- [taler-taler-mdb] 29/93: dce,
gnunet <=
- [taler-taler-mdb] 48/93: comment added, gnunet, 2019/11/18
- [taler-taler-mdb] 64/93: qr gen, gnunet, 2019/11/18
- [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