/usr/include/echonest/Config.h is in libechonest-dev 2.1.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | /****************************************************************************************
* Copyright (c) 2010-2012 Leo Franchi <lfranchi@kde.org> *
* *
* This program 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 2 of the License, or (at your option) any later *
* version. *
* *
* This program 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 *
* this program. If not, see <http://www.gnu.org/licenses/>. *
****************************************************************************************/
#ifndef ECHONEST_CONFIG_H
#define ECHONEST_CONFIG_H
#include "echonest_export.h"
#include <QByteArray>
#include <QUrl>
#include <exception>
#include <QNetworkReply>
class QNetworkAccessManager;
namespace Echonest{
/// Creates the base URL for all GET and POST requests
QUrl baseUrl();
/// Creates the base URL for GET requests.
QUrl baseGetQuery( const QByteArray& type, const QByteArray& method );
enum ErrorType {
/**
* Echo Nest API errors
*/
UnknownError = -1,
NoError = 0,
MissingAPIKey = 1,
NotAllowed = 2,
RateLimitExceeded = 3,
MissingParameter = 4,
InvalidParameter = 5,
/// libechonest errors
UnfinishedQuery = 6, /// An unfinished QNetworkReply* was passed to the parse function
EmptyResult = 7,
UnknownParseError = 8,
/// QNetworkReply errors
NetworkError = 9
};
class ECHONEST_EXPORT ParseError : public std::exception
{
public:
explicit ParseError( ErrorType error );
ParseError( ErrorType error, const QString& text );
virtual ~ParseError() throw();
ErrorType errorType() const throw();
/**
* If the ErrorType is NetworkError, this value contains the QNetworkReply
* error code that was returned.
*/
void setNetworkError( QNetworkReply::NetworkError error ) throw();
QNetworkReply::NetworkError networkError() const throw();
virtual const char* what() const throw ();
private:
ErrorType type;
QString extraText;
QNetworkReply::NetworkError nError;
};
class ConfigPrivate;
/**
* This singleton contains miscellaneous settings used to access The Echo Nest
*/
class ECHONEST_EXPORT Config {
public:
static Config* instance();
/**
* Set the API key to be used for all API requests. This MUST be set in order
* for any web service calls to work!
*/
void setAPIKey( const QByteArray& apiKey );
QByteArray apiKey() const;
/**
* Set the QNetworkAccessManager to use to make web service requests to
* The Echo Nest.
*
* This will register the given QNAM for the current thread. If you call this from
* the main thread and only make calls to libechonest from the main thread, you don't
* have to do any more work. However, if you are using multiple QNAMs in different threads,
* you must call this for each QNAM in each thread so that libechonest can use the proper
* thread-local QNAM. This function is thread-safe.
*
* Note that in all threads, if you do not set a QNAM, a default one is created and returned.
* In addition, if you set your own QNAM, you are responsible for deleting it.
*
* This will take over control of the object.
*/
void setNetworkAccessManager( QNetworkAccessManager* nam );
QNetworkAccessManager* nam() const;
private:
Config();
~Config();
static Config* s_instance;
ConfigPrivate* d;
};
}
#endif
|