• Main Page
  • Namespaces
  • Classes
  • Files
  • File List

src/interface.h

00001 /***************************************************************************
00002  *   Copyright (C) 2009-2010 by Dominik Kapusta       <d@ayoy.net>         *
00003  *                                                                         *
00004  *   This library is free software; you can redistribute it and/or modify  *
00005  *   it under the terms of the GNU Lesser General Public License as        *
00006  *   published by the Free Software Foundation; either version 2.1 of      *
00007  *   the License, or (at your option) any later version.                   *
00008  *                                                                         *
00009  *   This library is distributed in the hope that it will be useful,       *
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00012  *   Lesser General Public License for more details.                       *
00013  *                                                                         *
00014  *   You should have received a copy of the GNU Lesser General Public      *
00015  *   License along with this library; if not, write to                     *
00016  *   the Free Software Foundation, Inc.,                                   *
00017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
00018  ***************************************************************************/
00019 
00020 
00028 #ifndef INTERFACE_H
00029 #define INTERFACE_H
00030 
00031 #include <QObject>
00032 
00033 #include <QtCrypto>
00034 
00035 #include "qoauth_global.h"
00036 #include "qoauth_namespace.h"
00037 
00038 class QNetworkAccessManager;
00039 class QNetworkReply;
00040 
00041 namespace QOAuth {
00042 
00043 class InterfacePrivate;
00044 
00045 class QOAUTH_EXPORT Interface : public QObject
00046 {
00047     Q_OBJECT
00048 
00049     Q_PROPERTY( QByteArray consumerKey READ consumerKey WRITE setConsumerKey )
00050     Q_PROPERTY( QByteArray consumerSecret READ consumerSecret WRITE setConsumerSecret )
00051     Q_PROPERTY( uint requestTimeout READ requestTimeout WRITE setRequestTimeout )
00052     Q_PROPERTY( bool ignoreSslErrors READ ignoreSslErrors WRITE setIgnoreSslErrors )
00053     Q_PROPERTY( int error READ error )
00054 
00055 public:
00056     Interface( QObject *parent = 0 );
00057     Interface( QNetworkAccessManager *manager, QObject *parent = 0 );
00058     virtual ~Interface();
00059 
00060     QNetworkAccessManager* networkAccessManager() const;
00061     void setNetworkAccessManager(QNetworkAccessManager *manager);
00062 
00063     bool ignoreSslErrors() const;
00064     void setIgnoreSslErrors(bool enabled);
00065 
00066     QByteArray consumerKey() const;
00067     void setConsumerKey( const QByteArray &consumerKey );
00068 
00069     QByteArray consumerSecret() const;
00070     void setConsumerSecret( const QByteArray &consumerSecret );
00071 
00072     uint requestTimeout() const;
00073     void setRequestTimeout( uint msec );
00074 
00075     int error() const;
00076 
00077     bool setRSAPrivateKey( const QString &key,
00078                            const QCA::SecureArray &passphrase = QCA::SecureArray() );
00079     bool setRSAPrivateKeyFromFile( const QString &filename,
00080                                    const QCA::SecureArray &passphrase = QCA::SecureArray() );
00081 
00082 
00083     ParamMap requestToken( const QString &requestUrl, HttpMethod httpMethod,
00084                            SignatureMethod signatureMethod = HMAC_SHA1, const ParamMap &params = ParamMap() );
00085 
00086     ParamMap accessToken( const QString &requestUrl, HttpMethod httpMethod, const QByteArray &token,
00087                           const QByteArray &tokenSecret, SignatureMethod signatureMethod = HMAC_SHA1,
00088                           const ParamMap &params = ParamMap() );
00089 
00090     QByteArray createParametersString( const QString &requestUrl, HttpMethod httpMethod,
00091                                        const QByteArray &token, const QByteArray &tokenSecret,
00092                                        SignatureMethod signatureMethod, const ParamMap &params, ParsingMode mode );
00093 
00094     QByteArray inlineParameters( const ParamMap &params, ParsingMode mode = ParseForRequestContent );
00095 
00096 
00097 protected:
00098     InterfacePrivate * const d_ptr;
00099 
00100 private:
00101     Q_DISABLE_COPY(Interface)
00102     Q_DECLARE_PRIVATE(Interface)
00103     Q_PRIVATE_SLOT(d_func(), void _q_parseReply(QNetworkReply *reply))
00104     Q_PRIVATE_SLOT(d_func(), void _q_setPassphrase(int id, const QCA::Event &event))
00105     Q_PRIVATE_SLOT(d_func(), void _q_handleSslErrors( QNetworkReply *reply,
00106                                                       const QList<QSslError> &errors ))
00107 
00108 #ifdef UNIT_TEST
00109     friend class Ut_Interface;
00110     friend class Ft_Interface;
00111 #endif
00112 };
00113 
00114 } // namespace QOAuth
00115 
00116 #endif // INTERFACE_H

Generated on Sun Aug 8 2010 for QOAuth by  doxygen 1.7.1