libqutim  0.3.1.0
sound.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** qutIM - instant messenger
4 **
5 ** Copyright © 2011 Aleksey Sidorov <gorthauer87@yandex.ru>
6 **
7 *****************************************************************************
8 **
9 ** $QUTIM_BEGIN_LICENSE$
10 ** This program is free software: you can redistribute it and/or modify
11 ** it under the terms of the GNU General Public License as published by
12 ** the Free Software Foundation, either version 3 of the License, or
13 ** (at your option) any later version.
14 **
15 ** This program is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 ** See the GNU General Public License for more details.
19 **
20 ** You should have received a copy of the GNU General Public License
21 ** along with this program. If not, see http://www.gnu.org/licenses/.
22 ** $QUTIM_END_LICENSE$
23 **
24 ****************************************************************************/
25 
26 #ifndef SOUND_H
27 #define SOUND_H
28 
29 #include "libqutim_global.h"
30 #include <QPointer>
31 #include <QVariant>
32 #include <QSharedDataPointer>
33 #include "notification.h"
34 
35 namespace qutim_sdk_0_3
36 {
37 class Message;
38 
39 class LIBQUTIM_EXPORT SoundBackend : public QObject
40 {
41  Q_OBJECT
42  Q_CLASSINFO("Service", "Sound")
43 public:
44  SoundBackend();
45  virtual ~SoundBackend() {}
46  virtual void playSound(const QString &filename) = 0;
47  virtual QStringList supportedFormats() = 0;
48 protected:
49  virtual void virtual_hook(int type, void *data);
50 };
51 
52 class SoundThemeData;
54 {
55 public:
56  SoundTheme(const QString name = QString());
57  SoundTheme(const SoundTheme &other);
58  SoundTheme(SoundThemeData *data);
59  ~SoundTheme();
60  SoundTheme &operator =(const SoundTheme &other);
61  QString path(Notification::Type type) const;
62  void setPath(Notification::Type type, QString path);
63  void play(Notification::Type type) const;
64  bool isNull() const;
65  QString themeName() const;
66  bool save();
67 protected:
68  QSharedDataPointer<SoundThemeData> d;
69 };
70 
71 class SoundThemeProviderPrivate;
73 {
74  Q_DISABLE_COPY(SoundThemeProvider)
75 public:
77  virtual ~SoundThemeProvider();
78  virtual bool setSoundPath(Notification::Type sound, const QString &file);
79  virtual QString soundPath(Notification::Type sound) = 0;
80  virtual QString themeName() = 0;
81  virtual bool saveTheme();
82 protected:
83  virtual void virtual_hook(int type, void *data);
84  QScopedPointer<SoundThemeProviderPrivate> p;
85 };
86 
87 class LIBQUTIM_EXPORT SoundThemeBackend : public QObject
88 {
89  Q_OBJECT
90 public:
91  virtual QStringList themeList() = 0;
92  virtual SoundThemeProvider *loadTheme(const QString &name) = 0;
93 };
94 
95 class LIBQUTIM_EXPORT Sound : public QObject
96 {
97  Q_OBJECT
98 public:
99  virtual ~Sound();
100  static Sound *instance();
101  static SoundTheme theme(const QString &name = QString());
102  static void play(Notification::Type type);
103  static QString currentThemeName();
104  static QStringList themeList();
105  static void setTheme(const QString &name);
106  static void setTheme(const SoundTheme &theme);
107 signals:
108  void currentThemeChanged(const QString &themeName);
109 private:
110  Sound();
111 };
112 
113 }
114 
115 #endif // SOUND_H
116 

Generated by Doxygen