summaryrefslogtreecommitdiffstats
path: root/src/PulseAudioQt/pulseobject_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/PulseAudioQt/pulseobject_p.h')
-rw-r--r--src/PulseAudioQt/pulseobject_p.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/PulseAudioQt/pulseobject_p.h b/src/PulseAudioQt/pulseobject_p.h
new file mode 100644
index 0000000..946b66c
--- /dev/null
+++ b/src/PulseAudioQt/pulseobject_p.h
@@ -0,0 +1,57 @@
+/*
+ SPDX-FileCopyrightText: 2018 Nicolas Fella <nicolas.fella@gmx.de>
+
+ SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
+*/
+#ifndef PULSEOBJECT_P_H
+#define PULSEOBJECT_P_H
+
+#include "debug.h"
+
+#include <QVariantMap>
+
+#include <pulse/introspect.h>
+
+#include "context.h"
+
+namespace PulseAudioQt
+{
+class PulseObjectPrivate
+{
+public:
+ explicit PulseObjectPrivate(PulseObject *q);
+ virtual ~PulseObjectPrivate();
+
+ PulseObject *q;
+ QVariantMap m_properties;
+ QString m_name;
+
+ template<typename PAInfo>
+ void updatePulseObject(PAInfo *info)
+ {
+ if (m_name != QString::fromUtf8(info->name)) {
+ m_name = QString::fromUtf8(info->name);
+ Q_EMIT q->nameChanged();
+ }
+ }
+
+ template<typename PAInfo>
+ void updateProperties(PAInfo *info)
+ {
+ m_properties.clear();
+ void *it = nullptr;
+ while (const char *key = pa_proplist_iterate(info->proplist, &it)) {
+ Q_ASSERT(key);
+ const char *value = pa_proplist_gets(info->proplist, key);
+ if (!value) {
+ qDebug() << "property" << key << "not a string";
+ continue;
+ }
+ Q_ASSERT(value);
+ m_properties.insert(QString::fromUtf8(key), QString::fromUtf8(value));
+ }
+ Q_EMIT q->propertiesChanged();
+ }
+};
+}
+#endif