- implemented the swipe and touch logic in QML
- Added a SHA1 hash verification of the downloaded resource file - Fixed the activation/deactivation of the QML UI to avoid burning the battery
This commit is contained in:
@@ -1,3 +1,25 @@
|
||||
#include <qplatformdefs.h>
|
||||
#include <QtOpenGL>
|
||||
|
||||
#if (defined FORCE_GLES)
|
||||
#undef GL_ES_VERSION_2_0
|
||||
#undef GL_VERSION_2_0
|
||||
#define GL_VERSION_ES_CM_1_1 1
|
||||
#ifndef GL_OES_VERSION_1_1
|
||||
#define glOrthof glOrtho
|
||||
#define glClearDepthf glClearDepth
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (defined FORCE_GLES)
|
||||
#undef GL_ES_VERSION_2_0
|
||||
#undef GL_VERSION_2_0
|
||||
#define GL_VERSION_ES_CM_1_1 1
|
||||
#define glOrthof glOrtho
|
||||
#define glClearDepthf glClearDepth
|
||||
#endif
|
||||
|
||||
|
||||
#include "corewrapper.h"
|
||||
|
||||
#define ACTUAL_SCREEN_WIDTH (SCREEN_WIDTH)
|
||||
@@ -38,10 +60,6 @@ WagicCore::WagicCore(QDeclarativeItem *parent) :
|
||||
setWidth(480);
|
||||
setHeight(272);
|
||||
|
||||
// BindKey is a static method, m_engine is not even initialized
|
||||
for (signed int i = sizeof(gDefaultBindings)/sizeof(gDefaultBindings[0]) - 1; i >= 0; --i)
|
||||
m_engine->BindKey(gDefaultBindings[i].keysym, gDefaultBindings[i].keycode);
|
||||
|
||||
g_startTimer.restart();
|
||||
m_lastTickCount = g_startTimer.elapsed();
|
||||
}
|
||||
@@ -125,7 +143,7 @@ void WagicCore::setActive(bool active)
|
||||
if(!m_active && active)
|
||||
{
|
||||
m_engine->Resume();
|
||||
#if (defined Q_WS_MAEMO_5) || (defined MEEGO_EDITION_HARMATTAN) || (defined Q_WS_ANDROID)
|
||||
#if (defined Q_WS_MAEMO_5) || defined(MEEGO_EDITION_HARMATTAN) || (defined Q_WS_ANDROID)
|
||||
// 30 fps max on mobile
|
||||
m_timerId = startTimer(33);
|
||||
#else
|
||||
@@ -138,8 +156,8 @@ void WagicCore::setActive(bool active)
|
||||
else if(m_active && !active)
|
||||
{
|
||||
m_engine->Pause();
|
||||
#if (defined Q_WS_MAEMO_5) || (defined MEEGO_EDITION_HARMATTAN) || (defined Q_WS_ANDROID)
|
||||
killTimer(timerId);
|
||||
#if (defined Q_WS_MAEMO_5) || defined(MEEGO_EDITION_HARMATTAN) || (defined Q_WS_ANDROID)
|
||||
killTimer(m_timerId);
|
||||
#endif
|
||||
m_active = active;
|
||||
emit activeChanged();
|
||||
@@ -250,11 +268,11 @@ void WagicCore::keyPressEvent(QKeyEvent *event)
|
||||
#if (defined Q_WS_MAEMO_5)
|
||||
case Qt::Key_F7:
|
||||
/* interrupt please */
|
||||
g_engine->HoldKey_NoRepeat(JGE_BTN_SEC);
|
||||
m_engine->HoldKey_NoRepeat(JGE_BTN_SEC);
|
||||
break;
|
||||
case Qt::Key_F8:
|
||||
/* next phase please */
|
||||
g_engine->HoldKey_NoRepeat(JGE_BTN_PREV);
|
||||
m_engine->HoldKey_NoRepeat(JGE_BTN_PREV);
|
||||
break;
|
||||
#endif // Q_WS_MAEMO_5
|
||||
case Qt::Key_F:
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#include "filedownloader.h"
|
||||
#include <QDir>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
FileDownloader::FileDownloader(QString localPath, QUrl url, QObject *parent) :
|
||||
QObject(parent), m_received(0), m_OK(false), m_done(false)
|
||||
FileDownloader::FileDownloader(QString localPath, QObject *parent) :
|
||||
QObject(parent), m_received(0), m_hash(""), m_OK(false)
|
||||
|
||||
{
|
||||
QDir dir(QDir::homePath());
|
||||
@@ -16,25 +17,28 @@ FileDownloader::FileDownloader(QString localPath, QUrl url, QObject *parent) :
|
||||
|
||||
QFile local(m_localPath);
|
||||
if(local.exists()) {
|
||||
m_done = true;
|
||||
return;
|
||||
computeHash(local);
|
||||
}
|
||||
if(!url.isEmpty())
|
||||
setDownloadUrl(url);
|
||||
}
|
||||
|
||||
void FileDownloader::setDownloadUrl(QUrl url)
|
||||
{
|
||||
connect(&m_WebCtrl, SIGNAL(finished(QNetworkReply*)),
|
||||
SLOT(fileDownloaded(QNetworkReply*)));
|
||||
if((!url.isEmpty()) && url.toString() != m_downloadUrl.toString())
|
||||
{
|
||||
connect(&m_WebCtrl, SIGNAL(finished(QNetworkReply*)),
|
||||
SLOT(fileDownloaded(QNetworkReply*)));
|
||||
|
||||
QNetworkRequest request(url);
|
||||
QNetworkReply* reply = m_WebCtrl.get(request);
|
||||
QNetworkRequest request(url);
|
||||
QNetworkReply* reply = m_WebCtrl.get(request);
|
||||
|
||||
connect(reply, SIGNAL(downloadProgress(qint64, qint64)),
|
||||
SLOT(downloadProgress(qint64, qint64)));
|
||||
connect(reply, SIGNAL(downloadProgress(qint64, qint64)),
|
||||
SLOT(downloadProgress(qint64, qint64)));
|
||||
|
||||
m_OK = m_tmp.open();
|
||||
m_OK = m_tmp.open();
|
||||
|
||||
m_downloadUrl.setUrl(url.toString());
|
||||
emit downloadUrlChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,3 +46,16 @@ FileDownloader::~FileDownloader()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void FileDownloader::computeHash(QFile& file)
|
||||
{
|
||||
QCryptographicHash crypto(QCryptographicHash::Sha1);
|
||||
file.open(QFile::ReadOnly);
|
||||
while(!file.atEnd()){
|
||||
crypto.addData(file.read(8192));
|
||||
}
|
||||
QByteArray hash = crypto.result();
|
||||
|
||||
m_hash = hash.toHex();
|
||||
emit hashChanged();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user