2012-12-31 23:37:39 +01:00
|
|
|
/* This file is part of Clementine.
|
|
|
|
Copyright 2012, Andreas Muttscheller <asfa194@gmail.com>
|
|
|
|
|
|
|
|
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/>.
|
|
|
|
*/
|
|
|
|
|
2016-02-11 16:11:31 +01:00
|
|
|
#include "networkremote/networkremotehelper.h"
|
2012-12-31 23:37:39 +01:00
|
|
|
|
2016-02-11 16:11:31 +01:00
|
|
|
#include "core/application.h"
|
|
|
|
#include "core/logging.h"
|
|
|
|
#include "networkremote/networkremote.h"
|
2016-02-15 18:35:45 +01:00
|
|
|
#include "playlist/playlistmanager.h"
|
2012-12-31 23:37:39 +01:00
|
|
|
|
2014-02-06 16:49:49 +01:00
|
|
|
NetworkRemoteHelper* NetworkRemoteHelper::sInstance = nullptr;
|
2012-12-31 23:37:39 +01:00
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
NetworkRemoteHelper::NetworkRemoteHelper(Application* app) : app_(app) {
|
2012-12-31 23:37:39 +01:00
|
|
|
app_ = app;
|
2014-02-07 16:34:20 +01:00
|
|
|
connect(this, SIGNAL(ReloadSettingsSig()), app_->network_remote(),
|
|
|
|
SLOT(ReloadSettings()));
|
|
|
|
connect(this, SIGNAL(StartServerSig()), app_->network_remote(),
|
|
|
|
SLOT(StartServer()));
|
|
|
|
connect(this, SIGNAL(SetupServerSig()), app_->network_remote(),
|
|
|
|
SLOT(SetupServer()));
|
2012-12-31 23:37:39 +01:00
|
|
|
|
2013-01-22 22:58:32 +01:00
|
|
|
// Start the server once the playlistmanager is initialized
|
2014-02-07 16:34:20 +01:00
|
|
|
connect(app_->playlist_manager(), SIGNAL(PlaylistManagerInitialized()), this,
|
|
|
|
SLOT(StartServer()));
|
2013-01-22 22:58:32 +01:00
|
|
|
|
2012-12-31 23:37:39 +01:00
|
|
|
sInstance = this;
|
|
|
|
}
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
NetworkRemoteHelper::~NetworkRemoteHelper() {}
|
2012-12-31 23:37:39 +01:00
|
|
|
|
|
|
|
void NetworkRemoteHelper::StartServer() {
|
|
|
|
emit SetupServerSig();
|
|
|
|
emit StartServerSig();
|
|
|
|
}
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
void NetworkRemoteHelper::ReloadSettings() { emit ReloadSettingsSig(); }
|
2012-12-31 23:37:39 +01:00
|
|
|
|
|
|
|
// For using in Settingsdialog, we haven't the appication there
|
|
|
|
NetworkRemoteHelper* NetworkRemoteHelper::Instance() {
|
|
|
|
if (!sInstance) {
|
|
|
|
// normally he shouldn't go here. Only for safety
|
2014-02-06 16:49:49 +01:00
|
|
|
return nullptr;
|
2012-12-31 23:37:39 +01:00
|
|
|
}
|
|
|
|
return sInstance;
|
|
|
|
}
|