2015-06-06 09:40:08 +08:00
|
|
|
/*
|
|
|
|
Copyright © 2015 by The qTox Project
|
|
|
|
|
|
|
|
This file is part of qTox, a Qt-based graphical interface for Tox.
|
|
|
|
|
|
|
|
qTox is libre 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.
|
|
|
|
|
|
|
|
qTox 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 qTox. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2015-01-30 00:36:22 +08:00
|
|
|
#ifndef TOXME_H
|
|
|
|
#define TOXME_H
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
#include <QMutex>
|
2015-02-20 07:47:13 +08:00
|
|
|
#include <memory>
|
2015-06-06 07:44:47 +08:00
|
|
|
#include "src/core/toxid.h"
|
2015-01-30 00:36:22 +08:00
|
|
|
|
|
|
|
class QNetworkAccessManager;
|
|
|
|
|
|
|
|
/// This class implements a client for the toxme.se API
|
|
|
|
/// The class is thread safe
|
|
|
|
/// May process events while waiting for blocking calls
|
|
|
|
class Toxme
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/// Converts a toxme.se address to a Tox ID, returns an empty ID on error
|
2015-05-18 04:55:50 +08:00
|
|
|
static ToxId lookup(QString address);
|
2015-01-30 00:36:22 +08:00
|
|
|
/// Creates a new toxme.se address associated with a Tox ID.
|
|
|
|
/// If keepPrivate, the address will not be published on toxme.se
|
|
|
|
/// The bio is a short optional description of yourself if you want to publish your address.
|
2015-05-18 04:55:50 +08:00
|
|
|
static bool createAddress(ToxId id, QString address,
|
2015-01-30 00:36:22 +08:00
|
|
|
bool keepPrivate=true, QString bio=QString());
|
2015-02-20 08:09:32 +08:00
|
|
|
/// Deletes the address associated with your current Tox ID
|
2015-05-18 04:55:50 +08:00
|
|
|
static bool deleteAddress(ToxId id);
|
2015-01-30 00:36:22 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
Toxme()=delete;
|
|
|
|
static QByteArray makeJsonRequest(QString json);
|
|
|
|
static QByteArray prepareEncryptedJson(int action, QString payload);
|
2015-02-20 07:47:13 +08:00
|
|
|
static int extractError(QString json);
|
2015-01-30 00:36:22 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
static const QString apiUrl;
|
2015-02-20 07:47:13 +08:00
|
|
|
static const unsigned char pinnedPk[];
|
2015-01-30 00:36:22 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // TOXME_H
|