view ui/sslconnection_curl.h @ 908:d1c951b3012d

Curl based implementation of sslconnection
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 13 Aug 2014 19:35:08 +0200
parents
children eaed02defe6a
line wrap: on
line source
#ifndef UI_SSLCONNECTION_CURL_H
#define UI_SSLCONNECTION_CURL_H
/* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
 * Software engineering by Intevation GmbH
 *
 * This file is Free Software under the GNU GPL (v>=2)
 * and comes with ABSOLUTELY NO WARRANTY!
 * See LICENSE.txt for details.
 */

#include "sslconnection.h"
#include <curl/curl.h>

#include <QTemporaryFile>

class SSLConnectionCurl : public SSLConnection
{
public:
    SSLConnectionCurl(const QString& url,
            const QByteArray& certificate = QByteArray());

    ~SSLConnectionCurl();

    /** @brief write */
    int write(const QByteArray& request);

    /**
     * @brief read at most len bytes and reset the connection
     *
     * @param [in] len Amount of bytes to read.
     *
     * @returns a byte array containing the data or
     * a NULL byte array on error*/
    QByteArray read(size_t len);

    /** @brief: Establish the connection
     *
     * @returns 0 on success otherwise an error or -1 is returned
     */
    int connect();
private:
    CURL *mCurl;
    QTemporaryFile mCertFile;
};

/**
 * @file sslconnection_curl.h
 * @brief SSLConnection utilizing libcurl for http.
 */
#endif // UI_SSLCONNECTION_CURL_H

http://wald.intevation.org/projects/trustbridge/