about summary refs log blame commit diff stats
path: root/src/otr/otrlib.h
blob: 454013e36451a7a08139831830db35e736518d27 (plain) (tree)
1
2
3
4
5

           
                                 
  
                                                            













                                                                       
                                                                      
  











                                                                                

   

                    


                               

                               
                                             
 


                             
                                                                                                   
 
                                                                                                                  
 

                                                                                                                      
 

                                                                                                               
 
                                                                                                                                           
 
      
/*
 * otrlib.h
 * vim: expandtab:ts=4:sts=4:sw=4
 *
 * Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
 *
 * This file is part of Profanity.
 *
 * Profanity 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 of the License, or
 * (at your option) any later version.
 *
 * Profanity 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 Profanity.  If not, see <https://www.gnu.org/licenses/>.
 *
 * In addition, as a special exception, the copyright holders give permission to
 * link the code of portions of this program with the OpenSSL library under
 * certain conditions as described in each individual source file, and
 * distribute linked combinations including the two.
 *
 * You must obey the GNU General Public License in all respects for all of the
 * code used other than OpenSSL. If you modify file(s) with this exception, you
 * may extend this exception to your version of the file(s), but you are not
 * obligated to do so. If you do not wish to do so, delete this exception
 * statement from your version. If you delete this exception statement from all
 * source files in the program, then also delete it here.
 *
 */

#ifndef OTR_OTRLIB_H
#define OTR_OTRLIB_H

OtrlPolicy otrlib_policy(void);

char* otrlib_start_query(void);

void otrlib_init_ops(OtrlMessageAppOps* ops);

void otrlib_init_timer(void);
void otrlib_poll(void);

ConnContext* otrlib_context_find(OtrlUserState user_state, const char* const recipient, char* jid);

void otrlib_end_session(OtrlUserState user_state, const char* const recipient, char* jid, OtrlMessageAppOps* ops);

gcry_error_t otrlib_encrypt_message(OtrlUserState user_state, OtrlMessageAppOps* ops, char* jid, const char* const to,
                                    const char* const message, char** newmessage);

int otrlib_decrypt_message(OtrlUserState user_state, OtrlMessageAppOps* ops, char* jid, const char* const from,
                           const char* const message, char** decrypted, OtrlTLV** tlvs);

void otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps* ops, ConnContext* context, OtrlTLV* tlvs, GHashTable* smp_initiators);

#endif
t; printf "\e[32mAll done. Be sure to add:\e[0m\n" echo "* * * * * $($REALPATH ./dscip)" printf "\e[32mTo your crontab! Usually by using \`crontab -e\`\e[0m\n\n" printf "\e[32mAlternatively, you can run dscip as a daemon by modifying DSCIP_DAEMON in config.sh\n" printf "and creating a daemon for your system's init system.\e[0m\n\n" cd "$CWD" } # Non-interactive Mode set +u if [ ! "$1" = "" ]; then set -u while getopts ':n:d:u:b:t:lh' options; do case "${options}" in n) # Name PROJECT_NAME="$OPTARG" ;; d) # Directory to install to. PROJECT_LOCATION="$OPTARG" ;; u) # Git Repo URL PROJECT_URL="$OPTARG" ;; b) # Git Branch (Optional) PROJECT_BRANCH="$OPTARG" ;; t) # Template Directory (Optional) TEMPLATE_DIR="$OPTARG" ;; h) # Show Help Screen help_screen exit 0 ;; l) # Show License show_license exit 0 ;; *) echo "Invalid command-line switch. Aborting. See -h for more info." exit 1 ;; esac done check_config install_dscip exit 0 fi set -u # Interactive Mode echo "Welcome to DSCIP setup. This script will ask you a few questions." echo "Notes:" echo " 1. This script should be running as the user that will be building the software." echo " 2. Must have a cron daemon with the command: crontab -e, available." echo "By default, the script runs in interactive mode. But you can use command-line switches" echo "to use the set up script non-interactively. Use -h for more info." printf "\n" echo "If you feel you are ready. Press enter, otherwise press Ctrl-C to cancel." read -r ALL_CORRECT="false" question_name() { PROJECT_NAME="" while [ "$PROJECT_NAME" = "" ]; do printf "What is the name of the project?: " read -r PROJECT_NAME done } question_location() { PROJECT_LOCATION="/home/$USER/$PROJECT_NAME" NEW_PROJECT_LOCATION="" printf 'Where do you want to install DSCIP? (Default: %s): ' "$PROJECT_LOCATION" read -r NEW_PROJECT_LOCATION if [ "$NEW_PROJECT_LOCATION" = "" ]; then return 0 else PROJECT_LOCATION="$NEW_PROJECT_LOCATION" fi } question_giturl() { PROJECT_URL="" while [ "$PROJECT_URL" = "" ]; do printf "What is the URL of your Git Repo?: " read -r PROJECT_URL done } question_gitbranch() { PROJECT_BRANCH="master" printf 'What branch from the Git Repo do you want to use? (Default: %s): ' "$PROJECT_BRANCH" read -r PROJECT_BRANCH if [ "$PROJECT_BRANCH" = "" ]; then PROJECT_BRANCH="master" fi } question_templates() { TEMPLATE_DIR="" printf "If you have a template directory of the pre,post,build,failed,config.sh scripts.\nEnter it's location here, otherwise press Enter: " read -r TEMPLATE_DIR } question_allcorrect() { echo "Is all this information correct? Press the number to edit specific variables:" echo "1. Project Name: $PROJECT_NAME" echo "2. DSCIP Location: $PROJECT_LOCATION" echo "3. Git URL: $PROJECT_URL" echo "4. Git Branch: $PROJECT_BRANCH" echo "5. Template Directory: $TEMPLATE_DIR" printf "\nIf all information is correct. Press Enter.\nOtherwise, use a number and then press enter to edit: " } question_name printf "\n" question_location printf "\n" question_giturl printf "\n" question_gitbranch printf "\n" question_templates printf "\n" CHOICE="" while [ "$ALL_CORRECT" = "false" ]; do question_allcorrect read -r CHOICE printf "\n" case "$CHOICE" in 1) question_name ;; 2) question_location ;; 3) question_giturl ;; 4) question_gitbranch ;; 5) question_templates ;; *) ALL_CORRECT="true" ;; esac printf "\n" done check_config install_dscip