2013-09-28 17:17:14 -03:00
|
|
|
#ifndef TWISTER_UTILS_H
|
|
|
|
#define TWISTER_UTILS_H
|
|
|
|
|
2013-10-08 18:39:07 -03:00
|
|
|
#include "json/json_spirit.h"
|
2013-09-28 17:17:14 -03:00
|
|
|
#include "libtorrent/entry.hpp"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2013-10-08 22:37:29 -03:00
|
|
|
#include <set>
|
|
|
|
|
|
|
|
// in-memory unencrypted DMs
|
|
|
|
struct StoredDirectMsg {
|
|
|
|
int64_t m_utcTime;
|
|
|
|
std::string m_text;
|
|
|
|
bool m_fromMe;
|
|
|
|
};
|
|
|
|
|
|
|
|
// in-memory data per wallet user
|
|
|
|
struct UserData {
|
|
|
|
std::set<std::string> m_following;
|
|
|
|
// m_directmsg key is the other username
|
|
|
|
std::map<std::string, std::list<StoredDirectMsg> > m_directmsg;
|
|
|
|
};
|
|
|
|
|
2013-09-28 17:17:14 -03:00
|
|
|
|
|
|
|
class twister_utils
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
twister_utils();
|
|
|
|
};
|
|
|
|
|
|
|
|
int load_file(std::string const& filename, std::vector<char>& v, int limit = 8000000);
|
|
|
|
int save_file(std::string const& filename, std::vector<char>& v);
|
|
|
|
|
|
|
|
json_spirit::Value entryToJson(const libtorrent::entry &e);
|
|
|
|
libtorrent::entry jsonToEntry(const json_spirit::Value &v);
|
|
|
|
|
2013-10-08 22:37:29 -03:00
|
|
|
int saveUserData(std::string const& filename, std::map<std::string,UserData> const &users);
|
|
|
|
int loadUserData(std::string const& filename, std::map<std::string,UserData> &users);
|
|
|
|
|
2013-09-28 17:17:14 -03:00
|
|
|
#endif // TWISTER_UTILS_H
|