Skip to content
This repository has been archived by the owner on May 3, 2019. It is now read-only.

Commit

Permalink
#48 Linux AppImage updater
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinDuquesnoy committed Jul 21, 2017
1 parent cc714ef commit 240cf89
Show file tree
Hide file tree
Showing 97 changed files with 441 additions and 388 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
BasedOnStyle: WebKit

Standard: Cpp11
ColumnLimit: 120
ColumnLimit: 150

# Disable reflow of qdoc comments: indentation rules are different.
# Translation comments are also excluded
Expand Down
2 changes: 1 addition & 1 deletion lib/MellowPlayer/Application/IFileDownloader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace MellowPlayer::Application
virtual bool isDownloading() const = 0;

signals:
void progressChanged();
void progressChanged(double progress);
void finished(bool success);
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

using namespace MellowPlayer::Application;

ListeningHistory::ListeningHistory(IListeningHistoryDataProvider &model, IPlayer &player,
IWorkDispatcher &workDispatcher, Settings &settings)
ListeningHistory::ListeningHistory(IListeningHistoryDataProvider &model, IPlayer &player, IWorkDispatcher &workDispatcher, Settings &settings)
: logger(LoggingManager::instance().getLogger("ListeningHistory")),
dataProvider(model),
player(player),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ namespace MellowPlayer::Application
{
Q_OBJECT
public:
ListeningHistory(IListeningHistoryDataProvider &model, IPlayer &player, IWorkDispatcher &workDispatcher,
Settings &settings);
ListeningHistory(IListeningHistoryDataProvider &model, IPlayer &player, IWorkDispatcher &workDispatcher, Settings &settings);

void initialize();
const QList<Application::ListeningHistoryEntry> &getEntries() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ namespace MellowPlayer::Application

bool equals(const ListeningHistoryEntry &other) const
{
return other.serviceName == serviceName && other.songUniqueId == songUniqueId
&& other.songTitle == songTitle && other.artist == artist && other.album == album && other.artUrl == artUrl;
return other.serviceName == serviceName && other.songUniqueId == songUniqueId && other.songTitle == songTitle && other.artist == artist
&& other.album == album && other.artUrl == artUrl;
}

bool operator==(const ListeningHistoryEntry &other) const
Expand Down
10 changes: 5 additions & 5 deletions lib/MellowPlayer/Application/Logging/LoggingMacros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ inline std::ostream &operator<<(std::ostream &os, const QString &string)
return os;
}

#define LOG(logger, logEvent, logLevel) \
{ \
std::stringstream ss; \
ss << logEvent; \
logger.log(ss.str(), logLevel, __FILE__, __LINE__); \
#define LOG(logger, logEvent, logLevel) \
{ \
std::stringstream ss; \
ss << logEvent; \
logger.log(ss.str(), logLevel, __FILE__, __LINE__); \
}

#define LOG_TRACE(logger, logEvent) LOG(logger, logEvent, LogLevel::Trace)
Expand Down
3 changes: 1 addition & 2 deletions lib/MellowPlayer/Application/Logging/LoggingManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ namespace MellowPlayer::Application
LoggingManager &operator=(const LoggingManager &) = delete;
LoggingManager &operator=(LoggingManager &&) = default;

static LoggingManager &initialize(ILoggerFactory &loggerFactory,
const LoggerConfig &defaultConfig = LoggerConfig());
static LoggingManager &initialize(ILoggerFactory &loggerFactory, const LoggerConfig &defaultConfig = LoggerConfig());
static LoggingManager &initialize(ILoggerFactory &loggerFactory, LogLevel logLevel);
static LoggingManager &instance();

Expand Down
9 changes: 3 additions & 6 deletions lib/MellowPlayer/Application/Player/CurrentPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ CurrentPlayer::CurrentPlayer(Players &players, StreamingServicesController &stre
: players(players), streamingServices(streamingServices), currentPlayer(nullptr)
{

connect(&streamingServices, &StreamingServicesController::currentChanged, this,
&CurrentPlayer::onCurrentServiceChanged);
connect(&streamingServices, &StreamingServicesController::currentChanged, this, &CurrentPlayer::onCurrentServiceChanged);

if (streamingServices.getCurrent() != nullptr)
onCurrentServiceChanged(streamingServices.getCurrent());
Expand Down Expand Up @@ -144,13 +143,11 @@ void CurrentPlayer::onCurrentServiceChanged(StreamingService *streamingService)
if (currentPlayer != nullptr) {
disconnect(currentPlayer.get(), &Player::currentSongChanged, this, &CurrentPlayer::currentSongChanged);
disconnect(currentPlayer.get(), &Player::positionChanged, this, &CurrentPlayer::positionChanged);
disconnect(currentPlayer.get(), &Player::playbackStatusChanged, this,
&CurrentPlayer::playbackStatusChanged);
disconnect(currentPlayer.get(), &Player::playbackStatusChanged, this, &CurrentPlayer::playbackStatusChanged);
disconnect(currentPlayer.get(), &Player::canSeekChanged, this, &CurrentPlayer::canSeekChanged);
disconnect(currentPlayer.get(), &Player::canGoNextChanged, this, &CurrentPlayer::canGoNextChanged);
disconnect(currentPlayer.get(), &Player::canGoPreviousChanged, this, &CurrentPlayer::canGoPreviousChanged);
disconnect(currentPlayer.get(), &Player::canAddToFavoritesChanged, this,
&CurrentPlayer::canAddToFavoritesChanged);
disconnect(currentPlayer.get(), &Player::canAddToFavoritesChanged, this, &CurrentPlayer::canAddToFavoritesChanged);
disconnect(currentPlayer.get(), &Player::volumeChanged, this, &CurrentPlayer::volumeChanged);
disconnect(currentPlayer.get(), &Player::isPlayingChanged, this, &CurrentPlayer::isPlayingChanged);
disconnect(currentPlayer.get(), &Player::isStoppedChanged, this, &CurrentPlayer::isStoppedChanged);
Expand Down
12 changes: 3 additions & 9 deletions lib/MellowPlayer/Application/Player/Song.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@ Song::Song() : uniqueId(""), title(""), artist(""), album(""), artUrl(""), durat
{
}

Song::Song(const QString &uniqueId, const QString &title, const QString &artist, const QString &album,
const QString &artUrl, double duration, bool isFavorite)
: uniqueId(uniqueId),
title(title),
artist(artist),
album(album),
artUrl(artUrl),
duration(duration),
isFavorite(isFavorite)
Song::Song(const QString &uniqueId, const QString &title, const QString &artist, const QString &album, const QString &artUrl, double duration,
bool isFavorite)
: uniqueId(uniqueId), title(title), artist(artist), album(album), artUrl(artUrl), duration(duration), isFavorite(isFavorite)
{
}

Expand Down
4 changes: 2 additions & 2 deletions lib/MellowPlayer/Application/Player/Song.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ namespace MellowPlayer::Application

public:
Song();
Song(const QString &uniqueId, const QString &title, const QString &artist, const QString &album,
const QString &artUrl, double duration, bool isFavorite);
Song(const QString &uniqueId, const QString &title, const QString &artist, const QString &album, const QString &artUrl, double duration,
bool isFavorite);

QString getUniqueId() const;
QString getTitle() const;
Expand Down
6 changes: 1 addition & 5 deletions lib/MellowPlayer/Application/Settings/Setting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ using namespace std;
using namespace MellowPlayer::Application;

Setting::Setting(Settings &settings, SettingsCategory &category, const Setting::Data &settingData)
: QObject(&category),
settingsProvider(settings.getSettingsProvider()),
settings(settings),
category(category),
data(settingData)
: QObject(&category), settingsProvider(settings.getSettingsProvider()), settings(settings), category(category), data(settingData)
{
}

Expand Down
3 changes: 1 addition & 2 deletions lib/MellowPlayer/Application/Settings/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
using namespace std;
using namespace MellowPlayer::Application;

Settings::Settings(ISettingsSchemaLoader &configurationLoader, ISettingsProvider &settingsProvider)
: settingsProvider(settingsProvider)
Settings::Settings(ISettingsSchemaLoader &configurationLoader, ISettingsProvider &settingsProvider) : settingsProvider(settingsProvider)
{
QJsonDocument jsonDocument = configurationLoader.load();
QJsonObject rootObject = jsonDocument.object();
Expand Down
3 changes: 1 addition & 2 deletions lib/MellowPlayer/Application/Settings/SettingsCategory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
using namespace std;
using namespace MellowPlayer::Application;

SettingsCategory::SettingsCategory(const SettingsCategory::Data &categoryData, Settings *appSettings)
: QObject(appSettings), data(categoryData)
SettingsCategory::SettingsCategory(const SettingsCategory::Data &categoryData, Settings *appSettings) : QObject(appSettings), data(categoryData)
{
for (int i = 0; i < data.parameters.count(); ++i) {
QJsonObject parameterObj = data.parameters.at(i).toObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ using namespace MellowPlayer::Application;
using namespace std;

StreamingService::StreamingService(const StreamingServiceMetadata &metadata, const Theme &theme)
: metadata(metadata),
theme(theme),
script(make_unique<StreamingServiceScript>(metadata.script, metadata.scriptPath))
: metadata(metadata), theme(theme), script(make_unique<StreamingServiceScript>(metadata.script, metadata.scriptPath))
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,7 @@ namespace MellowPlayer::Application
*/
QString version;

StreamingServiceMetadata()
: author(""),
authorWebsite(""),
logoPath(""),
name(""),
url(""),
script(""),
scriptPath(""),
version("")
StreamingServiceMetadata() : author(""), authorWebsite(""), logoPath(""), name(""), url(""), script(""), scriptPath(""), version("")
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

using namespace MellowPlayer::Application;

StreamingServiceScript::StreamingServiceScript(const QString &code, const QString &path)
: QObject(), code(code), path(path)
StreamingServiceScript::StreamingServiceScript(const QString &code, const QString &path) : QObject(), code(code), path(path)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@ using namespace MellowPlayer::Application;
using namespace MellowPlayer::Application;
using namespace std;

StreamingServicesController::StreamingServicesController(IStreamingServiceLoader &loader,
IStreamingServiceWatcher &watcher)
: logger(LoggingManager::instance().getLogger("StreamingServicesController")),
loader(loader),
watcher(watcher),
current(nullptr)
StreamingServicesController::StreamingServicesController(IStreamingServiceLoader &loader, IStreamingServiceWatcher &watcher)
: logger(LoggingManager::instance().getLogger("StreamingServicesController")), loader(loader), watcher(watcher), current(nullptr)
{
}

Expand All @@ -32,8 +28,7 @@ void StreamingServicesController::load()
if (!found) {
LOG_DEBUG(logger, "service added: " + newService->getName());
services.append(newService);
if (!newService->getPluginDirectory().startsWith("/usr/")
&& !newService->getPluginDirectory().startsWith("/tmp/"))
if (!newService->getPluginDirectory().startsWith("/usr/") && !newService->getPluginDirectory().startsWith("/tmp/"))
watcher.watch(*newService);
emit added(newService.get());
}
Expand Down
4 changes: 2 additions & 2 deletions lib/MellowPlayer/Application/Theme/Theme.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ namespace MellowPlayer::Application

bool isEmpty() const
{
return accent.isEmpty() || background.isEmpty() || foreground.isEmpty() || primary.isEmpty()
|| primaryForeground.isEmpty() || secondary.isEmpty() || secondaryForeground.isEmpty();
return accent.isEmpty() || background.isEmpty() || foreground.isEmpty() || primary.isEmpty() || primaryForeground.isEmpty()
|| secondary.isEmpty() || secondaryForeground.isEmpty();
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ using namespace MellowPlayer::Application;

AbstractPlatformUpdater::AbstractPlatformUpdater(IFileDownloader &fileDownloader) : fileDownloader_(fileDownloader)
{
connect(&fileDownloader, &IFileDownloader::progressChanged, this, &AbstractPlatformUpdater::progressUpdated);
connect(&fileDownloader, &IFileDownloader::finished, this, &AbstractPlatformUpdater::downloadFinished);
}

Expand All @@ -19,7 +20,7 @@ void AbstractPlatformUpdater::download()
{
if (release_) {
assetFilePath_ = makeDestinationPath();
fileDownloader_.download(release_->getUrl(), assetFilePath_);
fileDownloader_.download(getAssetUrl(), assetFilePath_);
}
}

Expand All @@ -32,5 +33,6 @@ QString AbstractPlatformUpdater::makeDestinationPath()

void AbstractPlatformUpdater::install()
{
emit progressUpdated(-1);
doInstall(assetFilePath_);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ namespace MellowPlayer::Application
public:
AbstractPlatformUpdater(IFileDownloader &fileDownloader);

void setRelease(const Release *release);
virtual void setRelease(const Release *release);
void download();
void install();
virtual void restart(){};

virtual bool canInstall() const = 0;

signals:
void downloadFinished(bool success);
void installFinished(bool success);
void progressUpdated(double progress);

protected:
virtual void doInstall(const QString &assetFilePath) = 0;
Expand Down
6 changes: 5 additions & 1 deletion lib/MellowPlayer/Application/Updater/Asset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

using namespace MellowPlayer::Application;

Asset::Asset() : Asset("", "")
{
}

Asset::Asset(const QString &name, const QString &url) : name_(name), url_(url)
{
}
Expand All @@ -12,7 +16,7 @@ QString Asset::getName() const
return name_;
}

QString Asset::getUrl()
QString Asset::getUrl() const
{
return url_;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/MellowPlayer/Application/Updater/Asset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ namespace MellowPlayer::Application
class Asset
{
public:
Asset();
Asset(const QString &name, const QString &url);

QString getName() const;
QString getUrl();
QString getUrl() const;

bool isAppImage() const;
bool isWindowsInstaller() const;
Expand Down
3 changes: 1 addition & 2 deletions lib/MellowPlayer/Application/Updater/Release.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ Release::Release(const QString &name, const QDate &date, QObject *parent)
{
}

Release::Release(const QString &url, const QString &name, const QDate &date, const AssetList &assets, bool preRelease,
QObject *parent)
Release::Release(const QString &url, const QString &name, const QDate &date, const AssetList &assets, bool preRelease, QObject *parent)
: QObject(parent), url_(url), name_(name), date_(date), preRelease_(preRelease), assets_(assets)
{
}
Expand Down
4 changes: 2 additions & 2 deletions lib/MellowPlayer/Application/Updater/Release.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ namespace MellowPlayer::Application
Q_PROPERTY(QString date READ getDate CONSTANT)
public:
Release(const QString &name, const QDate &date, QObject *parent = nullptr);
Release(const QString &url, const QString &name, const QDate &date, const AssetList &assets,
bool preRelease = false, QObject *parent = nullptr);
Release(const QString &url, const QString &name, const QDate &date, const AssetList &assets, bool preRelease = false,
QObject *parent = nullptr);

QString getUrl() const;
QString getName() const;
Expand Down
Loading

0 comments on commit 240cf89

Please sign in to comment.