2010-03-24 21:58:17 +01:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-03-24 21:58:17 +01:00
|
|
|
|
|
|
|
Clementine is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "mpris.h"
|
2011-01-08 16:31:14 +01:00
|
|
|
#include "mpris1.h"
|
|
|
|
#include "mpris2.h"
|
2010-03-24 21:58:17 +01:00
|
|
|
|
2011-01-08 16:31:14 +01:00
|
|
|
#include <QFuture>
|
|
|
|
#include <QFutureWatcher>
|
|
|
|
#include <QtConcurrentRun>
|
2010-03-24 21:58:17 +01:00
|
|
|
|
2010-12-04 23:27:58 +01:00
|
|
|
namespace mpris {
|
|
|
|
|
2011-01-08 16:31:14 +01:00
|
|
|
Mpris::Mpris(Player* player, ArtLoader* art_loader, QObject* parent)
|
|
|
|
: QObject(parent),
|
|
|
|
player_(player),
|
|
|
|
art_loader_(art_loader),
|
|
|
|
mpris1_(NULL),
|
|
|
|
mpris2_(NULL)
|
2010-12-04 23:27:58 +01:00
|
|
|
{
|
2011-01-10 00:14:44 +01:00
|
|
|
qDebug() << __PRETTY_FUNCTION__;
|
|
|
|
|
2011-01-08 16:31:14 +01:00
|
|
|
QFuture<void> future = QtConcurrent::run(this, &Mpris::Init);
|
2010-11-21 16:13:26 +01:00
|
|
|
|
2011-01-08 16:31:14 +01:00
|
|
|
QFutureWatcher<void>* watcher = new QFutureWatcher<void>(this);
|
|
|
|
watcher->setFuture(future);
|
2010-11-21 16:13:26 +01:00
|
|
|
|
2011-01-08 16:31:14 +01:00
|
|
|
connect(watcher, SIGNAL(finished()), SLOT(Initialised()));
|
2010-11-21 16:13:26 +01:00
|
|
|
}
|
2010-12-04 23:27:58 +01:00
|
|
|
|
2011-01-08 16:31:14 +01:00
|
|
|
void Mpris::Init() {
|
2011-01-10 00:14:44 +01:00
|
|
|
qDebug() << __PRETTY_FUNCTION__ << "- starting";
|
|
|
|
qDebug() << __PRETTY_FUNCTION__ << "- registering MPRIS1";
|
2011-01-08 16:31:14 +01:00
|
|
|
mpris1_ = new mpris::Mpris1(player_, art_loader_);
|
2011-01-10 00:14:44 +01:00
|
|
|
qDebug() << __PRETTY_FUNCTION__ << "- registering MPRIS2";
|
2011-01-08 16:31:14 +01:00
|
|
|
mpris2_ = new mpris::Mpris2(player_, art_loader_, mpris1_);
|
2010-11-21 16:13:26 +01:00
|
|
|
|
2011-01-08 16:31:14 +01:00
|
|
|
mpris1_->moveToThread(thread());
|
|
|
|
mpris2_->moveToThread(thread());
|
2010-11-21 16:13:26 +01:00
|
|
|
|
2011-01-08 16:31:14 +01:00
|
|
|
mpris1_->setParent(this);
|
|
|
|
mpris2_->setParent(this);
|
2010-11-21 16:13:26 +01:00
|
|
|
|
2011-01-08 16:31:14 +01:00
|
|
|
connect(mpris2_, SIGNAL(RaiseMainWindow()), SIGNAL(RaiseMainWindow()));
|
2011-01-10 00:14:44 +01:00
|
|
|
|
|
|
|
qDebug() << __PRETTY_FUNCTION__ << "- complete";
|
2010-11-21 16:13:26 +01:00
|
|
|
}
|
|
|
|
|
2011-01-08 16:31:14 +01:00
|
|
|
void Mpris::Initialised() {
|
2011-01-10 00:14:44 +01:00
|
|
|
qDebug() << __PRETTY_FUNCTION__;
|
2011-01-08 16:31:14 +01:00
|
|
|
mpris2_->InitLibIndicate();
|
2010-11-21 16:13:26 +01:00
|
|
|
}
|
2010-12-04 23:27:58 +01:00
|
|
|
|
|
|
|
} // namespace mpris
|