2012-01-19 07:44:59 -06:00
|
|
|
#ifndef CLIENT_H
|
|
|
|
#define CLIENT_H
|
|
|
|
|
|
|
|
#include <queue>
|
2012-01-19 14:10:05 -06:00
|
|
|
#include <vector>
|
2012-01-31 12:49:14 -06:00
|
|
|
#include <fstream>
|
2012-01-19 14:10:05 -06:00
|
|
|
|
2012-01-19 11:59:00 -06:00
|
|
|
#include "Config.h"
|
2012-01-19 07:44:59 -06:00
|
|
|
#include "HTTP.h"
|
2012-02-11 10:08:59 -06:00
|
|
|
#include "preview/Comment.h"
|
2012-01-19 07:44:59 -06:00
|
|
|
#include "search/Thumbnail.h"
|
2012-01-19 14:10:05 -06:00
|
|
|
#include "search/Save.h"
|
2012-01-19 07:44:59 -06:00
|
|
|
#include "Singleton.h"
|
2012-01-25 11:21:55 -06:00
|
|
|
#include "User.h"
|
2012-01-19 07:44:59 -06:00
|
|
|
|
2012-01-31 12:49:14 -06:00
|
|
|
#include "cajun/reader.h"
|
|
|
|
#include "cajun/writer.h"
|
|
|
|
#include "cajun/elements.h"
|
|
|
|
|
2012-01-28 13:56:13 -06:00
|
|
|
enum LoginStatus {
|
2012-01-24 18:57:39 -06:00
|
|
|
LoginOkay, LoginError
|
2012-01-24 14:19:19 -06:00
|
|
|
};
|
|
|
|
|
2012-01-28 13:56:13 -06:00
|
|
|
enum RequestStatus {
|
|
|
|
RequestOkay, RequestFailure
|
|
|
|
};
|
|
|
|
|
|
|
|
class Client: public Singleton<Client> {
|
2012-01-19 07:44:59 -06:00
|
|
|
private:
|
2012-01-19 14:10:05 -06:00
|
|
|
std::string lastError;
|
2012-01-28 13:56:13 -06:00
|
|
|
|
|
|
|
//Auth session
|
|
|
|
User authUser;
|
|
|
|
|
|
|
|
//Thumbnail retreival
|
2012-01-19 07:44:59 -06:00
|
|
|
int thumbnailCacheNextID;
|
2012-01-19 11:59:00 -06:00
|
|
|
Thumbnail * thumbnailCache[THUMB_CACHE_SIZE];
|
|
|
|
void * activeThumbRequests[IMGCONNS];
|
|
|
|
int activeThumbRequestTimes[IMGCONNS];
|
|
|
|
int activeThumbRequestCompleteTimes[IMGCONNS];
|
|
|
|
std::string activeThumbRequestIDs[IMGCONNS];
|
2012-01-19 07:44:59 -06:00
|
|
|
public:
|
2012-01-31 12:49:14 -06:00
|
|
|
//Config file handle
|
|
|
|
json::Object configDocument;
|
|
|
|
|
2012-01-19 07:44:59 -06:00
|
|
|
Client();
|
|
|
|
~Client();
|
2012-01-28 13:56:13 -06:00
|
|
|
|
|
|
|
RequestStatus ExecVote(int saveID, int direction);
|
2012-01-29 18:40:28 -06:00
|
|
|
RequestStatus UploadSave(Save * save);
|
2012-01-28 13:56:13 -06:00
|
|
|
|
2012-01-25 19:13:33 -06:00
|
|
|
unsigned char * GetSaveData(int saveID, int saveDate, int & dataLength);
|
2012-01-25 11:21:55 -06:00
|
|
|
LoginStatus Login(string username, string password, User & user);
|
2012-01-19 07:44:59 -06:00
|
|
|
void ClearThumbnailRequests();
|
2012-02-12 10:47:01 -06:00
|
|
|
std::vector<Save*> * SearchSaves(int start, int count, string query, string sort, bool showOwn, int & resultCount);
|
2012-02-11 10:08:59 -06:00
|
|
|
std::vector<Comment*> * GetComments(int saveID, int start, int count);
|
2012-01-23 16:53:57 -06:00
|
|
|
Thumbnail * GetPreview(int saveID, int saveDate);
|
2012-01-19 07:44:59 -06:00
|
|
|
Thumbnail * GetThumbnail(int saveID, int saveDate);
|
2012-01-23 16:53:57 -06:00
|
|
|
Save * GetSave(int saveID, int saveDate);
|
2012-01-28 13:56:13 -06:00
|
|
|
void SetAuthUser(User user);
|
|
|
|
User GetAuthUser();
|
2012-03-22 17:12:16 -05:00
|
|
|
std::vector<string> * RemoveTag(int saveID, string tag);
|
|
|
|
std::vector<string> * AddTag(int saveID, string tag);
|
2012-01-28 13:56:13 -06:00
|
|
|
std::string GetLastError() {
|
|
|
|
return lastError;
|
|
|
|
}
|
2012-01-19 07:44:59 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CLIENT_H
|