-QT += webkit xml sql\r
+QT += webkit xml sql network\r
\r
INCLUDEPATH += $$PWD \\r
$$PWD/model \\r
symbian {\r
ICON = $$PWD/pkg/symbian/book.svgt\r
TARGET.UID3 = 0xEA633557\r
- # FIXME: TARGET.CAPABILITY = ...\r
+ TARGET.CAPABILITY = NetworkServices\r
# FIXME: Include path to OpenC ZLIB?\r
INCLUDEPATH += c:/Qt/4.7.0/src/3rdparty/zlib\r
HEADERS += widgets/flickcharm.h\r
#include "progress.h"
#include "dyalog.h"
#include "translucentbutton.h"
+#include "platform.h"
#ifdef DORIAN_TEST_MODEL
# include "modeltest.h"
#endif
-const int PROGRESS_HEIGHT = 17;
-static const char *DORIAN_VERSION =
-#include "pkg/version.txt"
-;
+const int DORIAN_PROGRESS_HEIGHT = 17;
MainWindow::MainWindow(QWidget *parent):
AdopterWindow(parent), view(0), preventBlankingTimer(-1)
otherChildren << progress << previousButton << nextButton;
takeChildren(view, otherChildren);
QRect geo = geometry();
- progress->setGeometry(0, 0, geo.width(), PROGRESS_HEIGHT);
+ progress->setGeometry(0, 0, geo.width(), DORIAN_PROGRESS_HEIGHT);
#if defined(Q_WS_MAEMO_5)
previousButton->setGeometry(0,
geo.height() - toolBar->height() - TranslucentButton::pixels,
QList<QWidget *> otherChildren;
otherChildren << progress << nextButton << previousButton;
QRect screen = QApplication::desktop()->screenGeometry();
- progress->setGeometry(0, 0, screen.width(), PROGRESS_HEIGHT);
+ progress->setGeometry(0, 0, screen.width(), DORIAN_PROGRESS_HEIGHT);
#if defined(Q_WS_MAEMO_5)
nextButton->setGeometry(screen.width() - TranslucentButton::pixels, 0,
TranslucentButton::pixels, TranslucentButton::pixels);
void MainWindow::resizeEvent(QResizeEvent *e)
{
Trace t("MainWindow::resizeEvent");
- progress->setGeometry(QRect(0, 0, e->size().width(), PROGRESS_HEIGHT));
+ progress->setGeometry(QRect(0, 0, e->size().width(), DORIAN_PROGRESS_HEIGHT));
#if defined(Q_WS_MAEMO_5)
previousButton->setGeometry(0,
e->size().height() - toolBar->height() - TranslucentButton::pixels,
"Akos Polster <akos@pipacs.com><br>"
"Licensed under GNU General Public License, Version 3<br>"
"Source code: <a href='https://garage.maemo.org/projects/dorian/'>"
- "garage.maemo.org/projects/dorian</a>").arg(DORIAN_VERSION));
+ "garage.maemo.org/projects/dorian</a>").arg(Platform::version()));
aboutDialog->addWidget(label);
aboutDialog->addStretch();
aboutDialog->show();
Package: dorian
Architecture: armel
-Depends: zlib1g, libqt4-core (>= 4.6.1), libqt4-gui (>= 4.6.1), libqt4-webkit (>= 4.6.1), libqt4-xml (>= 4.6.1), libqt4-dbus (>= 4.6.1), libqt4-sql (>= 4.6.1), libqt4-sql-sqlite (>= 4.6.1), mce
+Depends: zlib1g, libqt4-core (>= 4.6.1), libqt4-gui (>= 4.6.1), libqt4-webkit (>= 4.6.1), libqt4-xml (>= 4.6.1), libqt4-dbus (>= 4.6.1), libqt4-sql (>= 4.6.1), libqt4-sql-sqlite (>= 4.6.1), libqt4-network (>= 4.6.1), mce
Description: E-book reader
Read books published in DRM-free EPUB format
XB-Maemo-Display-Name: Dorian
# define DORIAN_ICON_PREFIX ":/icons/"
#endif
+static const char *DORIAN_VERSION =
+#include "pkg/version.txt"
+;
+
QString Platform::dbPath()
{
QString base(QDir::home().absoluteFilePath(DORIAN_BASE));
Q_UNUSED(argv);
#endif
}
+
+QString Platform::version()
+{
+ return QString(DORIAN_VERSION);
+}
static QString dbPath();
static QString icon(const QString &name);
static void restart(char *argv[]);
+ static QString version();
};
#endif // PLATFORM_H
+#include <QNetworkAccessManager>
+#include <QNetworkReply>
+#include <QNetworkRequest>
+
#include "search.h"
+#include "platform.h"
+#include "trace.h"
Search *inst = 0;
inst = 0;
}
-Search::Search(): QObject(0)
+Search::Search(): QObject(0), reply(0)
{
+ manager = new QNetworkAccessManager(this);
+ connect(manager, SIGNAL(finished(QNetworkReply *)),
+ this, SLOT(onFinished(QNetworkReply *)));
}
void Search::start(const Query &query)
{
+ Trace t("Search::start");
+
emit beginSearch();
- emit endSearch();
+
+ QNetworkRequest request;
+ request.setUrl(QUrl("http://www.gutenberg.org/catalog/world/results"));
+ // request.setRawHeader("User-Agent", "Dorian " + Platform::version());
+ QByteArray data;
+ data = "title=" + QUrl::toPercentEncoding(query.title) + "&author=" +
+ QUrl::toPercentEncoding(query.author);
+ qDebug() << "Request:" << data;
+ reply = manager->post(request, data);
+ connect(reply, SIGNAL(finished()), this, SLOT(finished()));
}
QList<Search::Result> Search::results()
emit endDownload();
return false;
}
+
+void Search::finished()
+{
+ Trace t("Search::finished");
+ QByteArray data = reply->readAll();
+ qDebug() << data;
+ reply->deleteLater();
+ emit endSearch();
+}
#include <QImage>
#include <QList>
+class QNetworkAccessManager;
+class QNetworkReply;
+
/** Search for books, display and download results. */
class Search: public QObject
{
void start(const Query &query);
QList<Result> results();
bool download(const Result &result, const QString &fileName);
+ void finished();
protected:
explicit Search();
+ QNetworkAccessManager *manager;
+ QNetworkReply *reply;
};
#endif // SEARCH_H
#include "searchdialog.h"
#include "search.h"
+#include "trace.h"
SearchDialog::SearchDialog(QWidget *parent): Dyalog(parent)
{
- setWindowTitle(tr("Search"));
+ setWindowTitle(tr("SearchDialog::SearchDialog"));
QLabel *titleLabel = new QLabel(tr("Title:"), this);
title = new QLineEdit(this);
Search::Query SearchDialog::query()
{
+ Trace t("SearchDialog::query");
Search::Query ret;
ret.title = title->text();
ret.author = author->text();
+ qDebug() << ret.title << ret.author;
return ret;
}