2
* KMix -- KDE's full featured mini mixer
4
* Copyright 2006-2007 Christian Esken <esken@kde.org>
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Library General Public
8
* License as published by the Free Software Foundation; either
9
* version 2 of the License, or (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Library General Public License for more details.
16
* You should have received a copy of the GNU Library General Public
17
* License along with this program; if not, write to the Free
18
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
#ifndef _GUIPROFILE_H_
22
#define _GUIPROFILE_H_
28
#include <QTextStream>
39
struct SortedStringComparator
41
bool operator()(const std::string&, const std::string&) const;
49
// In case the vendor ships different products under the same productName
50
QString productRelease;
54
class ProfControlPrivate
57
// List of controls, e.g: "rec:1-2,recswitch"
58
// THIS IS RAW DATA AS LOADED FROM THE PROFILE. DO NOT USE IT, except for debugging.
66
ProfControl(QString& id, QString& subcontrols);
67
ProfControl(const ProfControl &ctl); // copy constructor
69
// ID as returned by the Mixer Backend, e.g. Master:0
72
void setSubcontrols(QString sctls);
73
bool useSubcontrolPlayback() {return _useSubcontrolPlayback;};
74
bool useSubcontrolCapture() {return _useSubcontrolCapture;};
75
bool useSubcontrolPlaybackSwitch() {return _useSubcontrolPlaybackSwitch;};
76
bool useSubcontrolCaptureSwitch() {return _useSubcontrolCaptureSwitch;};
77
bool useSubcontrolEnum() {return _useSubcontrolEnum;};
78
QString renderSubcontrols();
80
QString getBackgroundColor() const { return backgroundColor; }
81
void setBackgroundColor(QString& backgroundColor) { this->backgroundColor = backgroundColor; }
82
QString getSwitchtype() const { return switchtype; }
83
void setSwitchtype(QString switchtype) { this->switchtype = switchtype; }
85
// Visible name for the User ( if name.isNull(), id will be used - And in the future a default lookup table will be consulted ).
86
// Because the name is visible, some kind of i18n() should be used.
88
// show or hide (contains the GUI type: simple, extended, all)
91
bool isMandatory() const
96
void setMandatory(bool _mandatory)
98
this->_mandatory = _mandatory;
100
void setSplit ( bool split ) {
103
bool isSplit() const {
108
// The following are the deserialized values of _subcontrols
109
bool _useSubcontrolPlayback;
110
bool _useSubcontrolCapture;
111
bool _useSubcontrolPlaybackSwitch;
112
bool _useSubcontrolCaptureSwitch;
113
bool _useSubcontrolEnum;
115
// For applying custom colors
116
QString backgroundColor;
117
// For defining the switch type when it is not a standard palyback or capture switch
120
bool _mandatory; // A mandatory control must be included in all GUIProfile copies
122
ProfControlPrivate *d;
123
bool _split; // true if this widget is to show two sliders
127
struct ProductComparator
129
bool operator()(const ProfProduct*, const ProfProduct*) const;
136
virtual ~GUIProfile();
138
bool readProfile(const QString& ref_fileNamestring);
139
bool finalizeProfile() const;
142
bool isDirty() const;
145
void setId(const QString& id);
146
QString getId() const;
147
QString getMixerId() const { return _mixerId; }
149
static QMap<QString, GUIProfile*>& getProfiles() { return s_profiles; }
151
unsigned long match(Mixer* mixer);
152
friend std::ostream& operator<<(std::ostream& os, const GUIProfile& vol);
153
friend QTextStream& operator<<(QTextStream &outStream, const GUIProfile& guiprof);
155
typedef std::set<ProfProduct*, ProductComparator> ProductSet;
158
ProductSet _products;
160
static GUIProfile* find(Mixer* mixer, QString profileName, bool profileNameIsFullyQualified, bool ignoreCardName);
161
static GUIProfile* selectProfileFromXMLfiles(Mixer*, QString preferredProfile);
162
static GUIProfile* fallbackProfile(Mixer*);
164
typedef QList<ProfControl*> ControlSet;
166
const ControlSet& getControls() const
170
ControlSet& getControls()
174
void setControls(ControlSet& newControlSet);
176
QString getName() const { return _name; }
177
void setName(QString _name) { this->_name = _name; }
179
// The values from the <soundcard> tag
180
QString _soundcardDriver;
181
// The driver version: 1000*1000*MAJOR + 1000*MINOR + PATCHLEVEL
182
unsigned long _driverVersionMin;
183
unsigned long _driverVersionMax;
184
QString _soundcardName;
185
QString _soundcardType;
186
unsigned long _generation;
188
ControlSet _controls;
191
static QString buildProfileName(Mixer* mixer, QString profileName, bool ignoreCard);
192
static QString buildReadableProfileName(Mixer* mixer, QString profileName);
194
static GUIProfile* loadProfileFromXMLfiles(Mixer* mixer, QString profileName);
195
static void addProfile(GUIProfile* guiprof);
196
static QMap<QString, GUIProfile*> s_profiles;
204
std::ostream& operator<<(std::ostream& os, const GUIProfile& vol);
205
QTextStream& operator<<(QTextStream &outStream, const GUIProfile& guiprof);
207
class GUIProfileParser : public QXmlDefaultHandler
210
GUIProfileParser(GUIProfile* ref_gp);
211
// Enumeration for the scope
212
enum ProfileScope { NONE, SOUNDCARD };
214
bool startDocument();
215
bool startElement( const QString&, const QString&, const QString& , const QXmlAttributes& );
216
bool endElement( const QString&, const QString&, const QString& );
219
void addControl(const QXmlAttributes& attributes);
220
void addProduct(const QXmlAttributes& attributes);
221
void addSoundcard(const QXmlAttributes& attributes);
222
void addProfileInfo(const QXmlAttributes& attributes);
223
void printAttributes(const QXmlAttributes& attributes);
224
void splitPair(const QString& pairString, std::pair<QString,QString>& result, char delim);
227
GUIProfile* _guiProfile;
230
#endif //_GUIPROFILE_H_