113 lines
3.6 KiB
C++
113 lines
3.6 KiB
C++
/*
|
|
* This file is part of libdanbooru.
|
|
* Copyright 2013 Luca Beltrame <lbeltrame@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) version 3 or any later version
|
|
* accepted by the membership of KDE e.V. (or its successor approved
|
|
* by the membership of KDE e.V.), which shall act as a proxy
|
|
* defined in Section 14 of version 3 of the license.
|
|
*
|
|
* 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 UTILS_H
|
|
#define UTILS_H
|
|
|
|
// Qt
|
|
|
|
#include <QtCore/QStringList>
|
|
|
|
// KDE
|
|
|
|
#include <kurl.h>
|
|
|
|
/**
|
|
* @brief Commmon utilities for Danbooru classes.
|
|
* @file utils.h
|
|
*
|
|
**/
|
|
|
|
namespace Danbooru {
|
|
|
|
typedef QMap<QString,QString> dictMap;
|
|
|
|
/** @brief Generate a request URL for a Danbooru board.
|
|
*
|
|
* Given an URL and an API path, this function builds a
|
|
* proper URL which is used for the specific API operation.
|
|
* The processing follows the "normal" way of encoding URLs.
|
|
*
|
|
* @param url The board URL.
|
|
* @param path The API path of the call to use
|
|
* @param username The username to supply (optional)
|
|
* @param password The password to use (optional)
|
|
* @param parameters A map of key,values representing the parameters
|
|
* to use.
|
|
* @param tags The tags to supply (optional).
|
|
*
|
|
* @return A constructed URL to be used for a Danbooru API call.
|
|
* @author Luca Beltrame (lbeltrame@kde.org)
|
|
*
|
|
*
|
|
**/
|
|
KUrl requestUrl(KUrl& url, const QString& path, const QString& username,
|
|
const QString& password, const dictMap& parameters,
|
|
const QStringList& tags);
|
|
|
|
|
|
/** @brief Generate a request URL for a Danbooru board.
|
|
*
|
|
* This is an overloaded function provided for convenience.
|
|
*
|
|
*
|
|
* @param url The board URL.
|
|
* @param path The API path of the call to use
|
|
* @param username The username to supply (optional)
|
|
* @param password The password to use (optional)
|
|
* @param parameters A map of key,values representing the parameters
|
|
* to use.
|
|
*
|
|
* @return A constructed URL to be used for a Danbooru API call.
|
|
* @author Luca Beltrame (lbeltrame@kde.org)
|
|
*
|
|
*
|
|
**/
|
|
KUrl requestUrl(KUrl& url, const QString& path, const QString& username,
|
|
const QString& password, const dictMap& parameters);
|
|
|
|
|
|
/** @brief Generate a request URL for a Danbooru board.
|
|
*
|
|
* This is an overloaded function provided for convenience.
|
|
*
|
|
* @param url The board URL.
|
|
* @param path The API path of the call to use
|
|
* @param username The username to supply (optional)
|
|
* @param password The password to use (optional)
|
|
*
|
|
* @return A constructed URL to be used for a Danbooru API call.
|
|
* @author Luca Beltrame (lbeltrame@kde.org)
|
|
*
|
|
*
|
|
**/
|
|
KUrl requestUrl(KUrl& url, const QString& path, const QString& username,
|
|
const QString& password);
|
|
|
|
|
|
QList<QVariant> parseDanbooruResult(QByteArray data, QString xlmElement,
|
|
bool* result);
|
|
QVariant parseDanbooruResult(QByteArray data, bool* result);
|
|
|
|
|
|
}
|
|
#endif // UTILS_H
|