#ifndef MALTRACKER_H #define MALTRACKER_H #include #include "nwutils.h" #include "onlinetracker.h" namespace Mal { enum UpdateWatchStatus { watching = 1, completed = 2, onhold = 3, dropped = 4, plantowatch = 6 }; class UpdateItem { public: UpdateItem(const TvShow*); static UpdateWatchStatus calculateWatchStatus(const TvShow::WatchStatus status); void describe(nw::Describer& de); QString toXml(); private: int episode; UpdateWatchStatus status; // int OR string. 1/watching, 2/completed, 3/onhold, 4/dropped, 6/plantowatch short score; // 0 - 10 int downloaded_episodes; int storage_type; // int (will be updated to accomodate strings soon) // yeah sure soon... float storage_value; // wat int times_rewatched; int rewatch_value; // no idea, displayed as "High", "Low" on the website or something QDate date_start; // date. mmddyyyy QDate date_finish; // date. mmddyyyy int priority; // 0 - 10 ? dont know didn't check short enable_discussion; // int. 1=enable, 0=disable short enable_rewatching; // int. 1=enable, 0=disable QString comments; // free text field? QString fansub_group; QStringList tags; // string. tags separated by commas }; class Tracker : public OnlineTracker { Q_OBJECT public: class Entry : public OnlineTracker::Entry { public: Entry(nw::Describer &de); int series_animedb_id; QString series_title; QString series_synonyms; int series_type; int series_episodes; int series_status; QDate series_start; //2004-10-05 QDate series_end; QString series_image; QString my_id; // always 0 no idea what it does int my_watched_episodes; QDate my_start_date; // 0000-00-00 QDate my_finish_date; // 0000-00-00 int my_score; TvShow::WatchStatus my_status; int my_rewatching; int my_rewatching_ep; uint my_last_updated; // unix time int example: 1388944557 QStringList my_tags; // separated by ", " virtual QDateTime lastUpdate() const { QDateTime t; t.setTime_t(my_last_updated); return t; } virtual int remoteId() const { return series_animedb_id; } virtual int watchedEpisodes() const { return my_watched_episodes; } virtual int rewatchMarker() const { return my_rewatching_ep; } virtual int rewatchCount() const { return my_rewatching; } virtual int totalEpisodes() const { return series_episodes; } virtual bool supportsRewatchMarker() const { return true; } virtual TvShow::WatchStatus getStatusWouldSendIfSynced(TvShow::WatchStatus showStatus) const; virtual TvShow::WatchStatus watchStatus() const { return my_status; } void describe(nw::Describer& de); static TvShow::WatchStatus restoreStatus(int malStatusId); }; class EntryList : public OnlineTracker::EntryList { public: EntryList(); virtual ~EntryList(); EntryList(nw::Describer& de); Entry* get(int remoteId); QList items; QString error; // should be empty void describe(nw::Describer& de); void updateShows(const QString trackerIdentifierKey, QList shows); const Entry* get(const QString trackerIdentifierKey, const TvShow* show) const; }; explicit Tracker(const OnlineCredentials& credentials, OnlineCredentials::TimeLock& lock, QObject *parent = 0); OnlineTracker::EntryList* fetchRemote(); const QString identifierKey() const; static const QString IDENTIFIER_KEY; /// This sounds like it makes 0 sense whatsoever, /// but mal-api is a huge pice of shit and the only way we can get /// infos about an entry by using it's id /// is by taking them from the already watching list. /// Oh fuck everything. void updateTrackingUnrelatedMetaDataFromRemote(TvShow* show, const OnlineTracker::EntryList& e) const; protected: virtual UpdateResult updateinOnlineTrackerOrAdd(const TvShow* show, const QString& type) const; signals: public slots: private: CURL* curlTrackerUpdateClient(const char* url, CurlResult& userdata, UpdateItem& data) const; }; } #endif // MALTRACKER_H