get-products-IMAGE_HASH-image.h (3632B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2014-2026 Taler Systems SA 4 5 TALER is free software; you can redistribute it and/or modify it under the 6 terms of the GNU Lesser General Public License as published by the Free Software 7 Foundation; either version 2.1, or (at your option) any later version. 8 9 TALER is distributed in the hope that it will be useful, but WITHOUT ANY 10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 12 13 You should have received a copy of the GNU Lesser General Public License along with 14 TALER; see the file COPYING.LGPL. If not, see 15 <http://www.gnu.org/licenses/> 16 */ 17 /** 18 * @file src/include/taler/merchant/get-products-IMAGE_HASH-image.h 19 * @brief C interface for GET /products/$IMAGE_HASH/image of the merchant backend 20 * @author Christian Grothoff 21 */ 22 #ifndef _TALER_MERCHANT__GET_PRODUCTS_IMAGE_HASH_IMAGE_H 23 #define _TALER_MERCHANT__GET_PRODUCTS_IMAGE_HASH_IMAGE_H 24 25 #include <taler/merchant/common.h> 26 27 28 /** 29 * Handle for a GET /products/$IMAGE_HASH/image request. 30 */ 31 struct TALER_MERCHANT_GetProductsImageHandle; 32 33 34 /** 35 * Response details for a GET /products/$IMAGE_HASH/image request. 36 */ 37 struct TALER_MERCHANT_GetProductsImageResponse 38 { 39 40 /** 41 * HTTP response details. 42 */ 43 struct TALER_MERCHANT_HttpResponse hr; 44 45 /** 46 * Details depending on the HTTP status code. 47 */ 48 union 49 { 50 51 /** 52 * Details on #MHD_HTTP_OK. 53 */ 54 struct 55 { 56 57 /** 58 * Image data (a data URI). 59 */ 60 const char *image; 61 62 } ok; 63 64 } details; 65 66 }; 67 68 69 /** 70 * Set up GET /products/$IMAGE_HASH/image operation. 71 * Note that you must explicitly start the operation after 72 * possibly setting options. 73 * 74 * @param ctx the context 75 * @param url base URL of the merchant backend 76 * @param image_hash hash identifying the image to retrieve 77 * @return handle to operation 78 */ 79 struct TALER_MERCHANT_GetProductsImageHandle * 80 TALER_MERCHANT_get_products_image_create ( 81 struct GNUNET_CURL_Context *ctx, 82 const char *url, 83 const char *image_hash); 84 85 86 #ifndef TALER_MERCHANT_GET_PRODUCTS_IMAGE_RESULT_CLOSURE 87 /** 88 * Type of the closure used by 89 * the #TALER_MERCHANT_GetProductsImageCallback. 90 */ 91 #define TALER_MERCHANT_GET_PRODUCTS_IMAGE_RESULT_CLOSURE void 92 #endif /* TALER_MERCHANT_GET_PRODUCTS_IMAGE_RESULT_CLOSURE */ 93 94 /** 95 * Callback for a GET /products/$IMAGE_HASH/image request. 96 * 97 * @param cls closure 98 * @param pgr response details 99 */ 100 typedef void 101 (*TALER_MERCHANT_GetProductsImageCallback)( 102 TALER_MERCHANT_GET_PRODUCTS_IMAGE_RESULT_CLOSURE *cls, 103 const struct TALER_MERCHANT_GetProductsImageResponse *pgr); 104 105 106 /** 107 * Start GET /products/$IMAGE_HASH/image operation. 108 * 109 * @param[in,out] gpi operation to start 110 * @param cb function to call with the merchant's result 111 * @param cb_cls closure for @a cb 112 * @return status code, #TALER_EC_NONE on success 113 */ 114 enum TALER_ErrorCode 115 TALER_MERCHANT_get_products_image_start ( 116 struct TALER_MERCHANT_GetProductsImageHandle *gpi, 117 TALER_MERCHANT_GetProductsImageCallback cb, 118 TALER_MERCHANT_GET_PRODUCTS_IMAGE_RESULT_CLOSURE *cb_cls); 119 120 121 /** 122 * Cancel GET /products/$IMAGE_HASH/image operation. This function 123 * must not be called by clients after the 124 * TALER_MERCHANT_GetProductsImageCallback has been invoked 125 * (as in those cases it'll be called internally by the 126 * implementation already). 127 * 128 * @param[in] gpi operation to cancel 129 */ 130 void 131 TALER_MERCHANT_get_products_image_cancel ( 132 struct TALER_MERCHANT_GetProductsImageHandle *gpi); 133 134 135 #endif /* _TALER_MERCHANT__GET_PRODUCTS_IMAGE_HASH_IMAGE_H */