#define SETUP_XBMC_PORT "xbmc/port"
#define SETUP_XBMC_PORT_DEFAULT "9090"
-// XBMC constants -- from https://github.com/xbmc/xbmc/blob/master/xbmc/guilib/Key.h
-#define ACTION_MOVE_LEFT 1
-#define ACTION_MOVE_RIGHT 2
-#define ACTION_MOVE_UP 3
-#define ACTION_MOVE_DOWN 4
-#define ACTION_NEXT_SUBTITLE 26 // switch to next subtitle of movie. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_SUBTITLE_DELAY_MIN 52 // Decrease subtitle/movie Delay. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_SUBTITLE_DELAY_PLUS 53 // Increase subtitle/movie Delay. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_AUDIO_DELAY_MIN 54 // Increase avsync delay. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_AUDIO_DELAY_PLUS 55 // Decrease avsync delay. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_AUDIO_NEXT_LANGUAGE 56 // Select next language in movie. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_ENTER 135
-#define ACTION_SHOW_GUI 18 // toggle between GUI and movie or GUI and visualisation.
-#define ACTION_STEP_FORWARD 20 // seek +1% in the movie. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_STEP_BACK 21 // seek -1% in the movie. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_BIG_STEP_FORWARD 22 // seek +10% in the movie. Can b used in videoFullScreen.xml window id=2005
-#define ACTION_BIG_STEP_BACK 23 // seek -10% in the movie. Can b used in videoFullScreen.xml window id=2005
-
-#define ACTION_PLAYER_PLAY 79 // Play current song. Unpauses song and sets playspeed to 1x. global action, can be used anywhere
-#define ACTION_SELECT_ITEM 7
-#define ACTION_HIGHLIGHT_ITEM 8
-#define ACTION_PARENT_DIR 9
-
#endif // SETTINGS_H
+++ /dev/null
-#include "json.h"
-
-int JsonEngine::id = 0;
-
-JsonEngine::JsonEngine()
-{
-}
-
-QString JsonEngine::serialize(const QString& method)
-{
- id++;
- return QString("{\"jsonrpc\" : \"2.0\", \"method\" : \"%1\", \"id\" : %2}")
- .arg(method)
- .arg(id);
-}
-
-QString JsonEngine::playerGetActivePlayers()
-{
- return serialize("Player.GetActivePlayers");
-}
-
-QString JsonEngine::videoPlayerState()
-{
- return serialize("VideoPlayer.State");
-}
-
-QString JsonEngine::videoPlayerPlayPause()
-{
- return serialize("VideoPlayer.PlayPause");
-}
+++ /dev/null
-#ifndef JSON_H
-#define JSON_H
-
-#include <QString>
-
-class JsonEngine
-{
- static int id;
-public:
- JsonEngine();
-
- QString playerGetActivePlayers();
- QString videoPlayerState();
- QString videoPlayerPlayPause();
-
- // make this private
- QString serialize(const QString& method);
-};
-
-#endif // JSON_H
#include "constants.h"
#include <QtGui/QApplication>
-#include <QMaemo5InformationBox>
int main(int argc, char *argv[])
{
mainWindow.setOrientation(MainWindow::ScreenOrientationAuto);
mainWindow.showExpanded();
-
return app.exec();
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
-#include "constants.h"
#include "setupdialog.h"
-#include "json.h"
+#include "xbmc.h"
#include <QCoreApplication>
-#include <QSettings>
-#include <QTimer>
-#include <QTextStream>
-#include <QNetworkReply>
#if defined(Q_OS_SYMBIAN) && defined(ORIENTATIONLOCK)
#include <eikenv.h>
#include <aknappui.h>
#endif // Q_OS_SYMBIAN && ORIENTATIONLOCK
-/////////////////////////////////////////////////////////////////////
-//
-DisconnectedState::DisconnectedState(QAbstractButton *button, QTcpSocket* socket, QState *parent)
- : QState(parent), m_socket(socket)
-{
- assignProperty(button, "text", "Connect");
- assignProperty(button, "enabled", true);
-}
-
-void DisconnectedState::onEntry(QEvent */*event*/)
-{
- qDebug("DisconnectedState::onEntry");
-}
-
-void DisconnectedState::onExit(QEvent */*event*/)
-{
- qDebug("DisconnectedState::onExit");
-}
-
-/////////////////////////////////////////////////////////////////////
-//
-ConnectingState::ConnectingState(QAbstractButton *button, QTcpSocket* socket, QState *parent)
- : QState(parent), m_socket(socket)
-{
- assignProperty(button, "text", "Connecting");
- assignProperty(button, "enabled", false);
-}
-
-void ConnectingState::onEntry(QEvent */*event*/)
-{
- qDebug("ConnectingState::onEntry");
-
- connect(m_socket, SIGNAL(connected()), this, SIGNAL(connected()));
- connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onSocketError(QAbstractSocket::SocketError)));
-
- // TODO: we asume the socket is not already connected
- // TODO: we should add code to do nothing if the connection is ok, or close and open a new one if the server or port changed
- QSettings settings;
-
- m_socket->connectToHost(settings.value(SETUP_XBMC_SERVER, SETUP_XBMC_SERVER_DEFAULT).toString(),
- settings.value(SETUP_XBMC_PORT, SETUP_XBMC_PORT_DEFAULT).toInt());
-}
-
-void ConnectingState::onExit(QEvent */*event*/)
-{
- disconnect(m_socket, 0, this, 0);
- qDebug("ConnectingState::onExit");
-}
-
-void ConnectingState::onSocketError(QAbstractSocket::SocketError)
-{
- qDebug("ConnectingState::onSocketError: %s", qPrintable(m_socket->errorString()));
- emit failed();
-}
-
-/////////////////////////////////////////////////////////////////////
-//
-ConnectedState::ConnectedState(QAbstractButton *button, QTcpSocket* socket, QState *parent)
- : QState(parent), m_socket(socket)
-{
- assignProperty(button, "text", "Disconnect");
- assignProperty(button, "enabled", true);
-}
-
-void ConnectedState::onEntry(QEvent */*event*/)
-{
- qDebug("ConnectedState::onEntry");
-
- connect(m_socket, SIGNAL(readyRead()), this, SLOT(onSocketData()));
- connect(m_socket, SIGNAL(disconnected()), this, SIGNAL(disconnected()));
- connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onSocketError(QAbstractSocket::SocketError)));
-}
-
-void ConnectedState::onExit(QEvent */*event*/)
-{
- disconnect(m_socket, 0, this, 0);
- qDebug("ConnectedState::onExit");
-}
-
-void ConnectedState::onSocketError(QAbstractSocket::SocketError)
-{
- qDebug("ConnectedState::onSocketError: %s", qPrintable(m_socket->errorString()));
-}
-
-void ConnectedState::onSocketData()
-{
- QTextStream stream(m_socket);
- QString msg = stream.readAll();
- qDebug("ConnectedState::onSocketData: %s", qPrintable(msg));
-}
-
-/////////////////////////////////////////////////////////////////////
-//
-DisconnectingState::DisconnectingState(QAbstractButton *button, QTcpSocket* socket, QState *parent)
- : QState(parent), m_socket(socket)
-{
- assignProperty(button, "text", "Disconnecting");
- assignProperty(button, "enabled", false);
-}
-
-void DisconnectingState::onEntry(QEvent */*event*/)
-{
- qDebug("DisconnectingState::onEntry");
-
- connect(m_socket, SIGNAL(disconnected()), this, SIGNAL(disconnected()));
- connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onSocketError(QAbstractSocket::SocketError)));
-
- if (m_socket->state() != QTcpSocket::UnconnectedState) {
- qDebug("DisconnectingState::disconnectFromHost");
- m_socket->disconnectFromHost();
- }
- else {
- qDebug("DisconnectingState::disconnect");
- QTimer::singleShot(0, this, SIGNAL(disconnected()));
- }
-}
-
-void DisconnectingState::onExit(QEvent */*event*/)
-{
- disconnect(m_socket, 0, this, 0);
- qDebug("DisconnectingState::onExit");
-}
-
-void DisconnectingState::onSocketError(QAbstractSocket::SocketError)
-{
- qDebug("DisconnectingState::onSocketError: %s", qPrintable(m_socket->errorString()));
-}
-
-/////////////////////////////////////////////////////////////////////
-//
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), m_ui(new Ui::MainWindow)
{
m_ui->setupUi(this);
- m_manager = new QNetworkAccessManager(this);
-
- createStates();
- createTransitions();
- createConnections();
-
- m_stateMachine.setInitialState(m_disconnectedState);
- QTimer::singleShot(0, &m_stateMachine, SLOT(start()));
+ m_xbmc = new Xbmc(this);
}
MainWindow::~MainWindow()
{
+ delete m_xbmc;
delete m_ui;
- delete m_manager;
}
void MainWindow::setOrientation(ScreenOrientation orientation)
}
}
-void MainWindow::createStates()
-{
- m_disconnectedState = new DisconnectedState(m_ui->networkButton, &m_serverSocket, &m_stateMachine);
- m_connectingState = new ConnectingState(m_ui->networkButton, &m_serverSocket, &m_stateMachine);
- m_connectedState = new ConnectedState(m_ui->networkButton, &m_serverSocket, &m_stateMachine);
- m_disconnectingState = new DisconnectingState(m_ui->networkButton, &m_serverSocket, &m_stateMachine);
-}
-
-void MainWindow::createTransitions()
-{
- m_disconnectedState->addTransition(m_ui->networkButton, SIGNAL(clicked()), m_connectingState);
-
- m_connectingState->addTransition(m_connectingState, SIGNAL(connected()), m_connectedState);
- m_connectingState->addTransition(m_connectingState, SIGNAL(failed()), m_disconnectedState);
-
- m_connectedState->addTransition(m_ui->networkButton, SIGNAL(clicked()), m_disconnectingState);
- m_connectedState->addTransition(m_connectedState, SIGNAL(disconnected()), m_disconnectedState);
-
- m_disconnectingState->addTransition(m_disconnectingState, SIGNAL(disconnected()), m_disconnectedState);
-}
-
-void MainWindow::createConnections()
-{
- connect(m_manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(onNetworAccesskManagerReplyFinished(QNetworkReply*)));
-}
-
-void MainWindow::on_videoPlayerStateBtn_clicked()
-{
- QTextStream stream(&m_serverSocket);
- stream << JsonEngine().videoPlayerState();
-}
-
-void MainWindow::on_videoPlayerPlayPauseBtn_clicked()
-{
- QTextStream stream(&m_serverSocket);
- stream << JsonEngine().videoPlayerPlayPause();
-}
-
-void MainWindow::on_videoPlayerStopBtn_clicked()
-{
- QTextStream stream(&m_serverSocket);
- stream << JsonEngine().serialize("VideoPlayer.Stop");
-}
-
-void MainWindow::on_videoPlayerSkipPreviousBtn_clicked()
-{
- QTextStream stream(&m_serverSocket);
- stream << JsonEngine().serialize("VideoPlayer.SkipPrevious");
-}
-
-void MainWindow::on_videoPlayerSkipNextBtn_clicked()
-{
- QTextStream stream(&m_serverSocket);
- stream << JsonEngine().serialize("VideoPlayer.SkipNext");
-}
-
-void MainWindow::on_videoPlayerBigSkipBackwardBtn_clicked()
-{
- QTextStream stream(&m_serverSocket);
- stream << JsonEngine().serialize("VideoPlayer.BigSkipBackward");
-}
-
-void MainWindow::on_videoPlayerBigSkipForwardBtn_clicked()
-{
- QTextStream stream(&m_serverSocket);
- stream << JsonEngine().serialize("VideoPlayer.BigSkipForward");
-}
-
-void MainWindow::on_videoPlayerSmallSkipBackwardBtn_clicked()
-{
- QTextStream stream(&m_serverSocket);
- stream << JsonEngine().serialize("VideoPlayer.SmallSkipBackward");
-}
-
-void MainWindow::on_videoPlayerSmallSkipForwardBtn_clicked()
-{
- QTextStream stream(&m_serverSocket);
- stream << JsonEngine().serialize("VideoPlayer.SmallSkipForward");
-}
-
-void MainWindow::on_videoPlayerGetTimeBtn_clicked()
-{
- QTextStream stream(&m_serverSocket);
- stream << JsonEngine().serialize("VideoPlayer.GetTime");
-}
-
-void MainWindow::on_xbmcGetVolumeBtn_clicked()
-{
- QTextStream stream(&m_serverSocket);
- stream << JsonEngine().serialize("XBMC.GetVolume");
-}
-
-void MainWindow::on_xbmcToggleMuteBtn_clicked()
-{
- QTextStream stream(&m_serverSocket);
- stream << JsonEngine().serialize("XBMC.ToggleMute");
-}
-
-void MainWindow::on_xbmcPlayBtn_clicked()
-{
- QTextStream stream(&m_serverSocket);
- stream << JsonEngine().serialize("XBMC.Play");
-}
-
-void MainWindow::on_xbmcQuitBtn_clicked()
-{
- QTextStream stream(&m_serverSocket);
- stream << JsonEngine().serialize("XBMC.Quit");
-}
-
-void MainWindow::on_playerGetActivePlayers_clicked()
-{
- QTextStream stream(&m_serverSocket);
- stream << JsonEngine().playerGetActivePlayers();
-}
-
-void MainWindow::on_actionLeftBtn_clicked()
-{
- m_manager->get(QNetworkRequest(QUrl(QString("http://localhost:8080/xbmcCmds/xbmcHttp?command=Action(%1)").arg(ACTION_MOVE_LEFT))));
-}
-
-void MainWindow::onNetworAccesskManagerReplyFinished(QNetworkReply *reply)
-{
- QTextStream stream(reply);
- QString msg = stream.readAll();
- qDebug("MainWindow::onNetworAccesskManagerReplyFinished: %s", qPrintable(msg));
-
- reply->deleteLater();
-}
-
-void MainWindow::on_actionRightBtn_clicked()
-{
- m_manager->get(QNetworkRequest(QUrl(QString("http://localhost:8080/xbmcCmds/xbmcHttp?command=Action(%1)").arg(ACTION_MOVE_RIGHT))));
-}
-
-void MainWindow::on_actionUpBtn_clicked()
-{
- m_manager->get(QNetworkRequest(QUrl(QString("http://localhost:8080/xbmcCmds/xbmcHttp?command=Action(%1)").arg(ACTION_MOVE_UP))));
-}
-
-void MainWindow::on_actionDownBtn_clicked()
-{
- m_manager->get(QNetworkRequest(QUrl(QString("http://localhost:8080/xbmcCmds/xbmcHttp?command=Action(%1)").arg(ACTION_MOVE_DOWN))));
-}
-
-void MainWindow::on_actionEnterBtn_clicked()
-{
- m_manager->get(QNetworkRequest(QUrl(QString("http://localhost:8080/xbmcCmds/xbmcHttp?command=Action(%1)").arg(ACTION_ENTER))));
-}
-
-void MainWindow::on_actionPlayBtn_clicked()
-{
- m_manager->get(QNetworkRequest(QUrl(QString("http://localhost:8080/xbmcCmds/xbmcHttp?command=Action(%1)").arg(ACTION_PLAYER_PLAY))));
-}
-
-void MainWindow::on_actionSelectItemBtn_clicked()
+void MainWindow::on_rightBtn_clicked()
{
- m_manager->get(QNetworkRequest(QUrl(QString("http://localhost:8080/xbmcCmds/xbmcHttp?command=Action(%1)").arg(ACTION_SELECT_ITEM))));
+ m_xbmc->actionMoveRight();
}
-void MainWindow::on_actionParentDirBtn_clicked()
+void MainWindow::on_leftBtn_clicked()
{
- m_manager->get(QNetworkRequest(QUrl(QString("http://localhost:8080/xbmcCmds/xbmcHttp?command=Action(%1)").arg(ACTION_PARENT_DIR))));
+ m_xbmc->actionMoveLeft();
}
#define MAINWINDOW_H
#include <QMainWindow>
-#include <QTcpSocket>
-#include <QStateMachine>
-#include <QState>
-#include <QAbstractButton>
-#include <QNetworkAccessManager>
+#include "xbmc.h"
namespace Ui {
class MainWindow;
}
-class DisconnectedState : public QState
-{
-public:
- DisconnectedState(QAbstractButton* button, QTcpSocket* socket, QState* parent = 0);
-
-protected:
- void onEntry(QEvent *event);
- void onExit(QEvent *event);
- QTcpSocket* m_socket;
-};
-
-class ConnectingState : public QState
-{
- Q_OBJECT
-public:
- ConnectingState(QAbstractButton* button, QTcpSocket* socket, QState* parent = 0);
-
-signals:
- void connected();
- void failed();
-
-private slots:
- void onSocketError(QAbstractSocket::SocketError err);
-
-protected:
- void onEntry(QEvent *event);
- void onExit(QEvent *event);
- QTcpSocket* m_socket;
-};
-
-class ConnectedState : public QState
-{
- Q_OBJECT
-public:
- ConnectedState(QAbstractButton* button, QTcpSocket* socket, QState* parent = 0);
-
-private slots:
- void onSocketError(QAbstractSocket::SocketError err);
- void onSocketData();
-
-signals:
- void disconnected();
-
-protected:
- void onEntry(QEvent *event);
- void onExit(QEvent *event);
- QTcpSocket* m_socket;
-};
-
-class DisconnectingState : public QState
-{
- Q_OBJECT
-public:
- DisconnectingState(QAbstractButton* button, QTcpSocket* socket, QState* parent = 0);
-
-signals:
- void disconnected();
-
-private slots:
- void onSocketError(QAbstractSocket::SocketError err);
-
-protected:
- void onEntry(QEvent *event);
- void onExit(QEvent *event);
- QTcpSocket* m_socket;
-};
-
class MainWindow : public QMainWindow
{
Q_OBJECT
void showExpanded();
private slots:
- // auto-connected slots
void on_actionSetup_triggered();
- void on_videoPlayerStateBtn_clicked();
- void on_videoPlayerPlayPauseBtn_clicked();
- void on_videoPlayerStopBtn_clicked();
- void on_videoPlayerSkipPreviousBtn_clicked();
- void on_videoPlayerSkipNextBtn_clicked();
- void on_videoPlayerBigSkipBackwardBtn_clicked();
- void on_videoPlayerBigSkipForwardBtn_clicked();
- void on_videoPlayerSmallSkipBackwardBtn_clicked();
- void on_videoPlayerSmallSkipForwardBtn_clicked();
- void on_videoPlayerGetTimeBtn_clicked();
- void on_xbmcGetVolumeBtn_clicked();
- void on_xbmcToggleMuteBtn_clicked();
- void on_xbmcPlayBtn_clicked();
- void on_xbmcQuitBtn_clicked();
- void on_playerGetActivePlayers_clicked();
- void on_actionLeftBtn_clicked();
-
- void onNetworAccesskManagerReplyFinished(QNetworkReply* reply);
- void on_actionRightBtn_clicked();
- void on_actionUpBtn_clicked();
- void on_actionDownBtn_clicked();
- void on_actionEnterBtn_clicked();
- void on_actionPlayBtn_clicked();
- void on_actionSelectItemBtn_clicked();
- void on_actionParentDirBtn_clicked();
+ void on_rightBtn_clicked();
+ void on_leftBtn_clicked();
private:
- void pendingNetworkOperation(bool pending);
-
- void createStates();
- void createTransitions();
- void createConnections();
-
- QTcpSocket m_serverSocket;
- QNetworkAccessManager *m_manager;
Ui::MainWindow *m_ui;
-
- QStateMachine m_stateMachine;
-
- DisconnectedState* m_disconnectedState;
- ConnectingState* m_connectingState;
- ConnectedState* m_connectedState;
- DisconnectingState* m_disconnectingState;
+ Xbmc* m_xbmc;
};
#endif // MAINWINDOW_H
<x>0</x>
<y>0</y>
<width>200</width>
- <height>320</height>
+ <height>335</height>
</rect>
</property>
<property name="windowTitle">
<string>XBMC Net Movies RC</string>
</property>
<widget class="QWidget" name="centralWidget">
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QPushButton" name="networkButton">
- <property name="text">
- <string>PushButton</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QStackedWidget" name="stackedWidget">
- <property name="currentIndex">
- <number>0</number>
- </property>
- <widget class="QWidget" name="infoPage">
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QToolButton" name="videoPlayerStateBtn">
- <property name="toolTip">
- <string>VideoPlayer.State</string>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QToolButton" name="videoPlayerPlayPauseBtn">
- <property name="toolTip">
- <string>VideoPlayer.PlayPause</string>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item row="0" column="2">
- <widget class="QToolButton" name="videoPlayerStopBtn">
- <property name="toolTip">
- <string>VideoPlayer.Stop</string>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QToolButton" name="actionLeftBtn">
- <property name="toolTip">
- <string>left</string>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QToolButton" name="xbmcGetVolumeBtn">
- <property name="toolTip">
- <string>XBMC.GetVolume</string>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QToolButton" name="videoPlayerBigSkipBackwardBtn">
- <property name="toolTip">
- <string>VideoPlayer.BigSkipBackward</string>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QToolButton" name="videoPlayerBigSkipForwardBtn">
- <property name="toolTip">
- <string>VideoPlayer.BigSkipForward</string>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item row="1" column="2">
- <widget class="QToolButton" name="videoPlayerSmallSkipBackwardBtn">
- <property name="toolTip">
- <string>VideoPlayer.SmallSkipBackward</string>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QToolButton" name="xbmcToggleMuteBtn">
- <property name="toolTip">
- <string>XBMC.ToggleMute</string>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item row="2" column="2">
- <widget class="QToolButton" name="xbmcPlayBtn">
- <property name="toolTip">
- <string>XBMC.Play</string>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QToolButton" name="actionRightBtn">
- <property name="toolTip">
- <string>right</string>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item row="3" column="2">
- <widget class="QToolButton" name="actionUpBtn">
- <property name="toolTip">
- <string>up</string>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item row="0" column="3">
- <widget class="QToolButton" name="videoPlayerSkipPreviousBtn">
- <property name="toolTip">
- <string>VideoPlayer.SkipPrevious</string>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item row="1" column="3">
- <widget class="QToolButton" name="videoPlayerSmallSkipForwardBtn">
- <property name="toolTip">
- <string>VideoPlayer.SmallSkipForward</string>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item row="2" column="3">
- <widget class="QToolButton" name="xbmcQuitBtn">
- <property name="toolTip">
- <string>XBMC.Quit</string>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item row="3" column="3">
- <widget class="QToolButton" name="actionDownBtn">
- <property name="toolTip">
- <string>down</string>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item row="3" column="4">
- <widget class="QToolButton" name="actionEnterBtn">
- <property name="toolTip">
- <string>enter</string>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item row="2" column="4">
- <widget class="QToolButton" name="playerGetActivePlayers">
- <property name="toolTip">
- <string>playerGetActivePlayers</string>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item row="1" column="4">
- <widget class="QToolButton" name="videoPlayerGetTimeBtn">
- <property name="toolTip">
- <string>VideoPlayer.GetTime</string>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item row="0" column="4">
- <widget class="QToolButton" name="videoPlayerSkipNextBtn">
- <property name="toolTip">
- <string>VideoPlayer.SkipNext</string>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QToolButton" name="actionPlayBtn">
- <property name="toolTip">
- <string>play</string>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="QToolButton" name="actionSelectItemBtn">
- <property name="toolTip">
- <string>select item</string>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item row="4" column="2">
- <widget class="QToolButton" name="actionParentDirBtn">
- <property name="toolTip">
- <string>parent dir</string>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QTextEdit" name="textEdit">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </widget>
- </item>
- </layout>
+ <widget class="QToolButton" name="downBtn">
+ <property name="geometry">
+ <rect>
+ <x>63</x>
+ <y>243</y>
+ <width>26</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="rightBtn">
+ <property name="geometry">
+ <rect>
+ <x>95</x>
+ <y>212</y>
+ <width>26</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="leftBtn">
+ <property name="geometry">
+ <rect>
+ <x>31</x>
+ <y>212</y>
+ <width>26</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="upBtn">
+ <property name="geometry">
+ <rect>
+ <x>63</x>
+ <y>181</y>
+ <width>26</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="playBtn">
+ <property name="geometry">
+ <rect>
+ <x>63</x>
+ <y>212</y>
+ <width>26</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="increaseAudioBtn">
+ <property name="geometry">
+ <rect>
+ <x>152</x>
+ <y>82</y>
+ <width>26</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="decreaseAudioBtn">
+ <property name="geometry">
+ <rect>
+ <x>152</x>
+ <y>113</y>
+ <width>26</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="muteBtn">
+ <property name="geometry">
+ <rect>
+ <x>150</x>
+ <y>170</y>
+ <width>26</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="nextSubtitleBtn">
+ <property name="geometry">
+ <rect>
+ <x>11</x>
+ <y>81</y>
+ <width>26</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="nextLanguageBtn">
+ <property name="geometry">
+ <rect>
+ <x>11</x>
+ <y>112</y>
+ <width>26</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="parentDirBtn">
+ <property name="geometry">
+ <rect>
+ <x>150</x>
+ <y>270</y>
+ <width>26</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
--- /dev/null
+#include "xbmc.h"
+#include "constants.h"
+
+#include <QSettings>
+#include <QTextStream>
+#include <QNetworkReply>
+
+// XBMC constants -- from https://github.com/xbmc/xbmc/blob/master/xbmc/guilib/Key.h
+#define ACTION_MOVE_LEFT 1
+#define ACTION_MOVE_RIGHT 2
+#define ACTION_MOVE_UP 3
+#define ACTION_MOVE_DOWN 4
+#define ACTION_NEXT_SUBTITLE 26 // switch to next subtitle of movie. Can b used in videoFullScreen.xml window id=2005
+#define ACTION_SUBTITLE_DELAY_MIN 52 // Decrease subtitle/movie Delay. Can b used in videoFullScreen.xml window id=2005
+#define ACTION_SUBTITLE_DELAY_PLUS 53 // Increase subtitle/movie Delay. Can b used in videoFullScreen.xml window id=2005
+#define ACTION_AUDIO_DELAY_MIN 54 // Increase avsync delay. Can b used in videoFullScreen.xml window id=2005
+#define ACTION_AUDIO_DELAY_PLUS 55 // Decrease avsync delay. Can b used in videoFullScreen.xml window id=2005
+#define ACTION_AUDIO_NEXT_LANGUAGE 56 // Select next language in movie. Can b used in videoFullScreen.xml window id=2005
+#define ACTION_ENTER 135
+#define ACTION_SHOW_GUI 18 // toggle between GUI and movie or GUI and visualisation.
+#define ACTION_STEP_FORWARD 20 // seek +1% in the movie. Can b used in videoFullScreen.xml window id=2005
+#define ACTION_STEP_BACK 21 // seek -1% in the movie. Can b used in videoFullScreen.xml window id=2005
+#define ACTION_BIG_STEP_FORWARD 22 // seek +10% in the movie. Can b used in videoFullScreen.xml window id=2005
+#define ACTION_BIG_STEP_BACK 23 // seek -10% in the movie. Can b used in videoFullScreen.xml window id=2005
+
+#define ACTION_PLAYER_PLAY 79 // Play current song. Unpauses song and sets playspeed to 1x. global action, can be used anywhere
+#define ACTION_SELECT_ITEM 7
+#define ACTION_HIGHLIGHT_ITEM 8
+#define ACTION_PARENT_DIR 9
+
+Xbmc::Xbmc(QObject *parent) : QObject(parent)
+{
+ m_manager = new QNetworkAccessManager(this);
+}
+
+Xbmc::~Xbmc()
+{
+ delete m_manager;
+}
+
+void Xbmc::do_command_action(int action)
+{
+ QSettings settings;
+ QString server = settings.value(SETUP_XBMC_SERVER, SETUP_XBMC_SERVER_DEFAULT).toString();
+ QString port = settings.value(SETUP_XBMC_PORT, SETUP_XBMC_PORT_DEFAULT).toString();
+
+ QString url = QString("http://%1:%2/xbmcCmds/xbmcHttp?command=Action(%3)")
+ .arg(server)
+ .arg(port)
+ .arg(action);
+
+ m_manager->get(QNetworkRequest(QUrl(url)));
+}
+
+void Xbmc::actionMoveRight()
+{
+ do_command_action(ACTION_MOVE_RIGHT);
+}
+
+void Xbmc::actionMoveLeft()
+{
+ do_command_action(ACTION_MOVE_LEFT);
+}
+
+void Xbmc::actionMoveUp()
+{
+ do_command_action(ACTION_MOVE_UP);
+}
+
+void Xbmc::actionMoveDown()
+{
+ do_command_action(ACTION_MOVE_DOWN);
+}
+
+//void MainWindow::onNetworAccesskManagerReplyFinished(QNetworkReply *reply)
+//{
+// QTextStream stream(reply);
+// QString msg = stream.readAll();
+// qDebug("MainWindow::onNetworAccesskManagerReplyFinished: %s", qPrintable(msg));
+
+// reply->deleteLater();
+//}
--- /dev/null
+#ifndef XBMC_H
+#define XBMC_H
+
+#include <QString>
+#include <QNetworkAccessManager>
+
+class Xbmc : public QObject
+{
+ Q_OBJECT
+public:
+ Xbmc(QObject* parent = 0);
+ ~Xbmc();
+
+ void actionMoveRight();
+ void actionMoveLeft();
+ void actionMoveUp();
+ void actionMoveDown();
+
+private:
+ void do_command_action(int action);
+
+ QNetworkAccessManager *m_manager;
+};
+
+#endif // XBMC_H
# Needs to be defined for Symbian
DEFINES += NETWORKACCESS
-QT += network maemo5
+QT += network
symbian:TARGET.UID3 = 0xED8FBFF1
SOURCES += main.cpp mainwindow.cpp \
setupdialog.cpp \
- json.cpp
+ xbmc.cpp
HEADERS += mainwindow.h \
setupdialog.h \
constants.h \
- json.h
+ xbmc.h
FORMS += mainwindow.ui \
setupdialog.ui