Skip to content

Commit

Permalink
Fix missing method
Browse files Browse the repository at this point in the history
  • Loading branch information
kraxarn committed Oct 14, 2023
1 parent 07568c2 commit 3c77a9c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
19 changes: 19 additions & 0 deletions src/enum/autoplaysupport.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

enum class AutoplaySupport: short
{
/**
* No support for overriding autoplay
*/
None,

/**
* Overriden by flag, (--autoplay)
*/
Flag,

/**
* Overriden by option (--autoplay true)
*/
Option,
};
16 changes: 13 additions & 3 deletions src/spotifyclient/helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,26 @@ auto SpotifyClient::Helper::running(const QString &path) -> bool
return QString(out).contains(path);
}

auto SpotifyClient::Helper::supportsAutoplay(const QString &path) -> bool
auto SpotifyClient::Helper::getAutoplaySupport(const QString &path) -> AutoplaySupport
{
if (clientType(path) != lib::client_type::librespot)
{
return false;
return AutoplaySupport::None;
}

const auto help = clientExec(path, {
QStringLiteral("--help"),
});

return help.contains(QStringLiteral("--autoplay"));
if (help.contains(QStringLiteral("--autoplay OVERRIDE")))
{
return AutoplaySupport::Option;
}

if (help.contains(QStringLiteral("--autoplay")))
{
return AutoplaySupport::Flag;
}

return AutoplaySupport::None;
}
6 changes: 3 additions & 3 deletions src/spotifyclient/helper.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "lib/enum/clienttype.hpp"
#include "enum/autoplaysupport.hpp"

#include <QStringList>
#include <QFileInfo>
Expand All @@ -20,11 +21,10 @@ namespace SpotifyClient
static auto running(const QString &path) -> bool;

/**
* Client supports --autoplay argument
* (librespot 0.4.2 and older only)
* What type of autoplay the client supports
* @param path Path to client
*/
static auto supportsAutoplay(const QString &path) -> bool;
static auto getAutoplaySupport(const QString &path) -> AutoplaySupport;

private:
Helper() = default;
Expand Down

0 comments on commit 3c77a9c

Please sign in to comment.