From 7f1ddb47d2b2289177b0bc8a917a7f093075e0e3 Mon Sep 17 00:00:00 2001 From: druid23 Date: Sun, 12 Sep 2010 13:19:53 +0100 Subject: [PATCH] Fix for Bug [#6295] Application polls vlc server even when the UI is not visible. Between catching the display on/off signal and being able to set your own timeoput periods I consider this solved for now at least. modified: src/playermainwindow.cpp modified: src/playermainwindow.h modified: src/src.pro --- src/playermainwindow.cpp | 40 +++++++++++++++++++++++++++++++++------- src/playermainwindow.h | 11 ++++++++++- src/src.pro | 3 ++- 3 files changed, 45 insertions(+), 9 deletions(-) diff --git a/src/playermainwindow.cpp b/src/playermainwindow.cpp index 8e16fcc..a2de15d 100644 --- a/src/playermainwindow.cpp +++ b/src/playermainwindow.cpp @@ -15,7 +15,7 @@ * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - #include + //#include #include #include #include "playermainwindow.h" @@ -26,10 +26,21 @@ #include "settingsdialog.h" #include "appsettings.h" #if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) -#include + #include + #include + #include + #include + #include + #include #endif #include +#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) +QDBusConnection PlayerMainWindow::dBusConnection = QDBusConnection::systemBus(); +QDBusInterface* PlayerMainWindow::dBusInterface = new QDBusInterface(MCE_SERVICE, MCE_REQUEST_PATH, + MCE_REQUEST_IF, dBusConnection); +#endif + PlayerMainWindow::PlayerMainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::PlayerMainWindow) @@ -71,6 +82,9 @@ #if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) + // Handle screen state on / off + dBusConnection.connect(MCE_SERVICE, MCE_SIGNAL_PATH, MCE_SIGNAL_IF, + MCE_DISPLAY_SIG, this, SLOT(displayStateChanged(const QDBusMessage &))); mPlayListMainWindow->setParent(this); mPlayListMainWindow->setAttribute(Qt::WA_Maemo5StackedWindow, true); @@ -183,6 +197,21 @@ } } +#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) + void PlayerMainWindow::displayStateChanged(const QDBusMessage &message) + { + QString state = message.arguments().at(0).toString(); + if (!state.isEmpty()) { + if (state == MCE_DISPLAY_ON_STRING) { + mTimer->start(AppSettings::getStatusPollTimeout()); + } + else if (state == MCE_DISPLAY_OFF_STRING) { + mTimer->stop(); + } + } + } +#endif + void PlayerMainWindow::showFavourites() { mFavouritesMainWindow->show(); mFavouritesMainWindow->init(); @@ -361,7 +390,6 @@ void PlayerMainWindow::askStatus() { - //qDebug() << "Status requested. at:" << QTime::currentTime().toString("hh::mm:ss"); if (AppSettings::isConnected()) { QNetworkReply * reply = mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/requests/status.xml"))); connect(reply,SIGNAL(readyRead()),this,SLOT(parseXmlStatus())); @@ -537,7 +565,8 @@ } } void PlayerMainWindow::error(QNetworkReply::NetworkError code) { - qDebug() << "Error Code: " << code; + Q_UNUSED(code); + //qDebug() << "Error Code: " << code; } void PlayerMainWindow::readReady() { QNetworkReply * reply = qobject_cast(sender()); @@ -552,7 +581,6 @@ delete reply; } void PlayerMainWindow::getCoverArt(int id) { - qDebug() << "getCoverArt id=!" << id; mResponse.clear(); QNetworkReply * reply = mNetManager->get(QNetworkRequest(QUrl("http://"+mIp+"/art?id=" + QString::number(id)))); connect(reply,SIGNAL(readyRead()),this,SLOT(readReady())); @@ -576,8 +604,6 @@ } } else { - qDebug() << "image load failed!"; - qDebug() << "data.length" << data.length(); ui->labelArtPortrait->setVisible(false); ui->labelArtLandscape->setVisible(false); } diff --git a/src/playermainwindow.h b/src/playermainwindow.h index 063508d..16ee1fe 100644 --- a/src/playermainwindow.h +++ b/src/playermainwindow.h @@ -26,6 +26,13 @@ #include "browsemainwindow.h" #include "favouritesmainwindow.h" #include "vlcstatus.h" +#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) + #include + #include + #include + #include + #include +#endif namespace Ui { class PlayerMainWindow; @@ -38,6 +45,7 @@ public: ~PlayerMainWindow(); public slots: + void displayStateChanged(const QDBusMessage &message); void askStatus(); void showSettings(); void showConfig(); @@ -92,7 +100,8 @@ private: bool mIsLandscape; bool mHasImage; bool mIsFirstStatusCall; - + static QDBusConnection dBusConnection; + static QDBusInterface* dBusInterface; }; #endif // PLAYERMAINWINDOW_H diff --git a/src/src.pro b/src/src.pro index a13c497..55d86ca 100644 --- a/src/src.pro +++ b/src/src.pro @@ -5,7 +5,8 @@ QT += core \ gui \ network \ xml \ - maemo5 + maemo5 \ + dbus TARGET = vlc-remote TEMPLATE = app SOURCES += main.cpp \ -- 1.7.9.5