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-04-24 08:32:09 +08:00
|
|
|
#include "src/core/corestructs.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
|
|
|
|
static ToxID lookup(QString address);
|
|
|
|
/// 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.
|
|
|
|
static bool createAddress(ToxID id, QString address,
|
|
|
|
bool keepPrivate=true, QString bio=QString());
|
2015-02-20 08:09:32 +08:00
|
|
|
/// Deletes the address associated with your current Tox ID
|
|
|
|
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
|