#ifndef CLIENT_H #define CLIENT_H #include #include #include #include #include "Config.h" #include "HTTP.h" #include "preview/Comment.h" #include "search/Thumbnail.h" #include "client/SaveInfo.h" #include "client/SaveFile.h" #include "Singleton.h" #include "User.h" #include "cajun/reader.h" #include "cajun/writer.h" #include "cajun/elements.h" enum LoginStatus { LoginOkay, LoginError }; enum RequestStatus { RequestOkay, RequestFailure }; class ClientListener; class Client: public Singleton { private: void * versionCheckRequest; bool updateAvailable; std::string lastError; list stampIDs; int lastStampTime; int lastStampName; //Auth session User authUser; //Thumbnail retreival int thumbnailCacheNextID; Thumbnail * thumbnailCache[THUMB_CACHE_SIZE]; void * activeThumbRequests[IMGCONNS]; int activeThumbRequestTimes[IMGCONNS]; int activeThumbRequestCompleteTimes[IMGCONNS]; std::string activeThumbRequestIDs[IMGCONNS]; void updateStamps(); void notifyUpdateAvailable(); public: vector listeners; //Config file handle json::Object configDocument; Client(); ~Client(); void AddListener(ClientListener * listener); RequestStatus ExecVote(int saveID, int direction); RequestStatus UploadSave(SaveInfo * save); SaveFile * GetStamp(string stampID); void DeleteStamp(string stampID); string AddStamp(GameSave * saveData); vector GetStamps(int start, int count); int GetStampsCount(); SaveFile * GetFirstStamp(); unsigned char * GetSaveData(int saveID, int saveDate, int & dataLength); LoginStatus Login(string username, string password, User & user); void ClearThumbnailRequests(); std::vector * SearchSaves(int start, int count, string query, string sort, string category, int & resultCount); std::vector * GetComments(int saveID, int start, int count); Thumbnail * GetPreview(int saveID, int saveDate); Thumbnail * GetThumbnail(int saveID, int saveDate); SaveInfo * GetSave(int saveID, int saveDate); RequestStatus DeleteSave(int saveID); RequestStatus ReportSave(int saveID, std::string message); RequestStatus UnpublishSave(int saveID); RequestStatus FavouriteSave(int saveID, bool favourite); void SetAuthUser(User user); User GetAuthUser(); std::vector * RemoveTag(int saveID, string tag); //TODO RequestStatus std::vector * AddTag(int saveID, string tag); std::string GetLastError() { return lastError; } void Tick(); }; #endif // CLIENT_H