gnunet-android

GNUnet for Android
Log | Files | Refs | README

gnunet_chat_uri.h (2669B)


      1 /*
      2    This file is part of GNUnet.
      3    Copyright (C) 2022--2025 GNUnet e.V.
      4 
      5    GNUnet is free software: you can redistribute it and/or modify it
      6    under the terms of the GNU Affero General Public License as published
      7    by the Free Software Foundation, either version 3 of the License,
      8    or (at your option) any later version.
      9 
     10    GNUnet is distributed in the hope that it will be useful, but
     11    WITHOUT ANY WARRANTY; without even the implied warranty of
     12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13    Affero General Public License for more details.
     14 
     15    You should have received a copy of the GNU Affero General Public License
     16    along with this program.  If not, see <http://www.gnu.org/licenses/>.
     17 
     18    SPDX-License-Identifier: AGPL3.0-or-later
     19  */
     20 /*
     21  * @author Tobias Frisch
     22  * @file gnunet_chat_uri.h
     23  */
     24 
     25 #ifndef GNUNET_CHAT_URI_H_
     26 #define GNUNET_CHAT_URI_H_
     27 
     28 #include <gnunet/gnunet_fs_service.h>
     29 #include <gnunet/gnunet_util_lib.h>
     30 #include <gnunet/gnunet_messenger_service.h>
     31 
     32 #include "gnunet_chat_util.h"
     33 
     34 struct GNUNET_CHAT_UriChat
     35 {
     36   struct GNUNET_CRYPTO_BlindablePublicKey zone;
     37   char *label;
     38 };
     39 
     40 struct GNUNET_CHAT_UriFile
     41 {
     42   struct GNUNET_FS_Uri *uri;
     43 };
     44 
     45 struct GNUNET_CHAT_Uri
     46 {
     47   enum GNUNET_CHAT_UriType type;
     48 
     49   union {
     50     struct GNUNET_CHAT_UriChat chat;
     51     struct GNUNET_CHAT_UriFile fs;
     52   };
     53 };
     54 
     55 /**
     56  * Creates a chat uri with a selected key as <i>zone</i>
     57  * and a <i>label</i> of type #GNUNET_CHAT_URI_TYPE_CHAT.
     58  *
     59  * @param[in] zone URI zone
     60  * @param[in] label URI label
     61  * @return New chat uri
     62  */
     63 struct GNUNET_CHAT_Uri*
     64 uri_create_chat (const struct GNUNET_CRYPTO_BlindablePublicKey *zone,
     65 	               const char *label);
     66 
     67 /**
     68  * Creates a chat uri from a selected FS <i>uri</i>
     69  * setting the type to #GNUNET_CHAT_URI_TYPE_FS.
     70  *
     71  * @param[in] uri FS URI
     72  * @return New chat uri
     73  */
     74 struct GNUNET_CHAT_Uri*
     75 uri_create_file (const struct GNUNET_FS_Uri *uri);
     76 
     77 /**
     78  * Destroys a chat <i>uri</i> and frees its memory.
     79  *
     80  * @param[in,out] uri Chat uri
     81  */
     82 void
     83 uri_destroy (struct GNUNET_CHAT_Uri *uri);
     84 
     85 /**
     86  * Parses an UTF-8 string to a chat URI which will 
     87  * be newly allocated.
     88  *
     89  * @param[in] string UTF-8 string to parse
     90  * @param[out] emsg Where to store the parser error message (if any)
     91  * @return URI on success, NULL on error
     92  */
     93 struct GNUNET_CHAT_Uri*
     94 uri_parse_from_string (const char *string,
     95                        char **emsg);
     96 
     97 /**
     98  * Returns an allocated UTF-8 string representing
     99  * a given chat <i>uri</i>.
    100  *
    101  * @param[in] uri Chat uri
    102  * @return The UTF-8 string representing the URI
    103  */
    104 char*
    105 uri_to_string (const struct GNUNET_CHAT_Uri *uri);
    106 
    107 #endif /* GNUNET_CHAT_URI_H_ */