X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=search.h;h=4908ac668d6d153877befa3ddd083805430c9f65;hb=d32af855518f5b94cda767f60c8a1b98b4602f99;hp=d577f2fba9dd0708ce7e47339a8ed459ef4dad12;hpb=5e79f668d0077d5134e91388755cf360ba36e2c7;p=dorian diff --git a/search.h b/search.h index d577f2f..4908ac6 100644 --- a/search.h +++ b/search.h @@ -7,12 +7,16 @@ #include #include +class QNetworkAccessManager; +class QNetworkReply; + /** Search for books, display and download results. */ class Search: public QObject { Q_OBJECT public: + /** Search query. */ struct Query { QString title; @@ -20,6 +24,7 @@ public: QStringList languages; }; + /** Search result. */ struct Result { QString id; @@ -28,6 +33,17 @@ public: QStringList authors; QString language; QImage cover; + bool operator ==(const Result &other) const { + return (source == other.source) && (id == other.id); + } + }; + + /** Download status. */ + enum + { + Ok, + DownloadError, + FileError, }; static Search *instance(); @@ -39,15 +55,25 @@ signals: void endSearch(); void beginDownload(int totalBlocks); void downloading(int blocks); - void endDownload(); + void endDownload(int status, const Search::Result &result, + const QString &fileName); public slots: void start(const Query &query); QList results(); - bool download(const Result &result, const QString &fileName); + void download(const Result &result, const QString &fileName); + void finished(); + void downloadFinished(); -protected: +private: explicit Search(); + QNetworkAccessManager *manager; + QNetworkAccessManager *downloadManager; + QNetworkReply *reply; + QNetworkReply *downloadReply; + QList searchResults; + Search::Result downloadResult; + QString downloadFileName; }; #endif // SEARCH_H