Skip to content

Commit 9691df5

Browse files
committed
feat: add --get-all argument
1 parent 78483d3 commit 9691df5

File tree

10 files changed

+63
-6
lines changed

10 files changed

+63
-6
lines changed

src/config/DspConfig.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,16 @@ class DspConfig :
215215
}
216216

217217

218-
void save()
219-
{
220-
auto file = AppConfig::instance().getDspConfPath();
221-
ConfigIO::writeFile(file, _conf->getConfigMap());
222-
}
218+
QString serialize()
219+
{
220+
return ConfigIO::writeString(_conf->getConfigMap());
221+
}
222+
223+
void save()
224+
{
225+
auto file = AppConfig::instance().getDspConfPath();
226+
ConfigIO::writeFile(file, _conf->getConfigMap());
227+
}
223228

224229
void load()
225230
{

src/main.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ int main(int argc,
167167
QCommandLineOption isConnected(QStringList() << "is-connected", "Check if JamesDSP service is active. Returns exit code 1 if not. (Remote)");
168168
QCommandLineOption status(QStringList() << "status", "Show status (Remote)");
169169
QCommandLineOption listKeys(QStringList() << "list-keys", "List available audio configuration keys (Remote)");
170+
QCommandLineOption getAll(QStringList() << "get-all", "Get all audio configuration values (Remote)");
170171
QCommandLineOption get(QStringList() << "get", "Get audio configuration value (Remote)", "key");
171172
QCommandLineOption set(QStringList() << "set", "Set audio configuration value (format: key=value) (Remote)", "key=value");
172173
QCommandLineOption loadPreset(QStringList() << "load-preset", "Load preset by name (Remote)", "name");
@@ -189,7 +190,7 @@ int main(int argc,
189190
parser.addOptions({silent, nocolor, minVerbosity});
190191

191192
// Remote control
192-
auto remoteCmds = {isConnected, listKeys, get, set, loadPreset, savePreset, deletePreset, listPresets, status};
193+
auto remoteCmds = {isConnected, listKeys, getAll, get, set, loadPreset, savePreset, deletePreset, listPresets, status};
193194
parser.addOptions(remoteCmds);
194195

195196
parser.process(*app.get());
@@ -246,6 +247,9 @@ int main(int argc,
246247
result = ctrl.set(out.first, out.second);
247248
}
248249
}
250+
else if(parser.isSet(getAll)) {
251+
result = ctrl.getAll();
252+
}
249253
else if(!parser.value(get).isEmpty()) {
250254
result = ctrl.get(parser.value(get));
251255
}

src/utils/CliRemoteController.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,25 @@ bool CliRemoteController::get(const QString &key) const
9191
return result.has_value();
9292
}
9393

94+
bool CliRemoteController::getAll() const
95+
{
96+
std::optional<QString> result;
97+
if(!checkConnectionAndLog()) {
98+
result = DspConfig::instance().serialize();
99+
}
100+
else {
101+
auto reply = service->getAll();
102+
auto received = handleReply<QString>(reply);
103+
result = received;
104+
}
105+
106+
if(result.has_value()) {
107+
Log::console(result.value(), true);
108+
}
109+
110+
return result.has_value();
111+
}
112+
94113
bool CliRemoteController::listKeys() const
95114
{
96115
QStringList keys;

src/utils/CliRemoteController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class CliRemoteController : public QObject
1414
bool isConnected() const;
1515
bool set(const QString& key, const QVariant& value) const;
1616
bool get(const QString& key) const;
17+
bool getAll() const;
1718
bool listKeys() const;
1819
bool listPresets() const;
1920
bool loadPreset(const QString& name) const;

src/utils/dbus/ClientProxy.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ public Q_SLOTS: // METHODS
105105
return asyncCallWithArgumentList(QStringLiteral("get"), argumentList);
106106
}
107107

108+
inline QDBusPendingReply<QString> getAll()
109+
{
110+
QList<QVariant> argumentList;
111+
return asyncCallWithArgumentList(QStringLiteral("getAll"), argumentList);
112+
}
113+
108114
inline QDBusPendingReply<QStringList> getKeys()
109115
{
110116
QList<QVariant> argumentList;

src/utils/dbus/IpcHandler.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ QString IpcHandler::get(const QString &key) const
9090
return value.toString();
9191
}
9292

93+
QString IpcHandler::getAll() const
94+
{
95+
return DspConfig::instance().serialize();
96+
}
97+
9398
void IpcHandler::set(const QString &key, const QDBusVariant &value) const
9499
{
95100
setInternal(key, value);

src/utils/dbus/IpcHandler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public slots:
4343
void set(const QString &key, const QDBusVariant &value) const;
4444
void setAndCommit(const QString &key, const QDBusVariant &value) const;
4545
QString get(const QString &key) const;
46+
QString getAll() const;
4647
QStringList getPresets() const;
4748
void loadPreset(const QString &name) const;
4849
void savePreset(const QString &name) const;

src/utils/dbus/ServerAdaptor.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ QString ServiceAdaptor::get(const QString &key)
111111
return value;
112112
}
113113

114+
QString ServiceAdaptor::getAll()
115+
{
116+
// handle method call me.timschneeberger.jdsp4linux.Service.getAll
117+
QString kvpairs;
118+
QMetaObject::invokeMethod(parent(), "getAll", Q_RETURN_ARG(QString, kvpairs));
119+
return kvpairs;
120+
}
121+
114122
QStringList ServiceAdaptor::getKeys()
115123
{
116124
// handle method call me.timschneeberger.jdsp4linux.Service.getKeys

src/utils/dbus/ServerAdaptor.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ class ServiceAdaptor: public QDBusAbstractAdaptor
6767
" <arg direction=\"in\" type=\"s\" name=\"key\"/>\n"
6868
" <arg direction=\"out\" type=\"s\" name=\"value\"/>\n"
6969
" </method>\n"
70+
" <method name=\"getAll\">\n"
71+
" <arg direction=\"out\" type=\"s\" name=\"kvpairs\"/>\n"
72+
" </method>\n"
7073
" <method name=\"set\">\n"
7174
" <arg direction=\"in\" type=\"s\" name=\"key\"/>\n"
7275
" <arg direction=\"in\" type=\"v\" name=\"value\"/>\n"
@@ -117,6 +120,7 @@ public Q_SLOTS: // METHODS
117120
void commit();
118121
void deletePreset(const QString &name);
119122
QString get(const QString &key);
123+
QString getAll();
120124
QStringList getKeys();
121125
QStringList getPresets();
122126
void loadPreset(const QString &name);

src/utils/dbus/manifest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
<arg name="value" type="s" direction="out"/>
2626
</method>
2727

28+
<method name="getAll">
29+
<arg name="kvpairs" type="s" direction="out"/>
30+
</method>
31+
2832
<method name="set">
2933
<arg name="key" type="s" direction="in"/>
3034
<arg name="value" type="v" direction="in"/>

0 commit comments

Comments
 (0)