libqutim 0.2.80.1

sound.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** qutIM - instant messenger
00004 **
00005 ** Copyright © 2011 Aleksey Sidorov <gorthauer87@yandex.ru>
00006 **
00007 *****************************************************************************
00008 **
00009 ** $QUTIM_BEGIN_LICENSE$
00010 ** This program is free software: you can redistribute it and/or modify
00011 ** it under the terms of the GNU General Public License as published by
00012 ** the Free Software Foundation, either version 3 of the License, or
00013 ** (at your option) any later version.
00014 **
00015 ** This program is distributed in the hope that it will be useful,
00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00018 ** See the GNU General Public License for more details.
00019 **
00020 ** You should have received a copy of the GNU General Public License
00021 ** along with this program.  If not, see http://www.gnu.org/licenses/.
00022 ** $QUTIM_END_LICENSE$
00023 **
00024 ****************************************************************************/
00025 
00026 #ifndef SOUND_H
00027 #define SOUND_H
00028 
00029 #include "libqutim_global.h"
00030 #include <QPointer>
00031 #include <QVariant>
00032 #include <QSharedDataPointer>
00033 #include "notification.h"
00034 
00035 namespace qutim_sdk_0_3
00036 {
00037 class Message;
00038 
00039 class LIBQUTIM_EXPORT SoundBackend : public QObject
00040 {
00041     Q_OBJECT
00042     Q_CLASSINFO("Service", "Sound")
00043 public:
00044     SoundBackend();
00045     virtual ~SoundBackend() {}
00046     virtual void playSound(const QString &filename) = 0;
00047     virtual QStringList supportedFormats() = 0;
00048 protected:
00049     virtual void virtual_hook(int type, void *data);
00050 };
00051 
00052 class SoundThemeData;
00053 class LIBQUTIM_EXPORT SoundTheme
00054 {
00055 public:
00056     SoundTheme(const QString name = QString());
00057     SoundTheme(const SoundTheme &other);
00058     SoundTheme(SoundThemeData *data);
00059     ~SoundTheme();
00060     SoundTheme &operator =(const SoundTheme &other);
00061     QString path(Notification::Type type) const;
00062     void setPath(Notification::Type type, QString path);
00063     void play(Notification::Type type) const;
00064     bool isNull() const;
00065     QString themeName() const;
00066     bool save();
00067 protected:
00068     QSharedDataPointer<SoundThemeData> d;
00069 };
00070 
00071 class SoundThemeProviderPrivate;
00072 class LIBQUTIM_EXPORT SoundThemeProvider
00073 {
00074     Q_DISABLE_COPY(SoundThemeProvider)
00075 public:
00076     SoundThemeProvider();
00077     virtual ~SoundThemeProvider();
00078     virtual bool setSoundPath(Notification::Type sound, const QString &file);
00079     virtual QString soundPath(Notification::Type sound) = 0;
00080     virtual QString themeName() = 0;
00081     virtual bool saveTheme();
00082 protected:
00083     virtual void virtual_hook(int type, void *data);
00084     QScopedPointer<SoundThemeProviderPrivate> p;
00085 };
00086 
00087 class LIBQUTIM_EXPORT SoundThemeBackend : public QObject
00088 {
00089     Q_OBJECT
00090 public:
00091     virtual QStringList themeList() = 0;
00092     virtual SoundThemeProvider *loadTheme(const QString &name) = 0;
00093 };
00094 
00095 class LIBQUTIM_EXPORT Sound : public QObject
00096 {
00097     Q_OBJECT
00098 public:
00099     virtual ~Sound();
00100     static Sound *instance();
00101     static SoundTheme theme(const QString &name = QString());
00102     static void play(Notification::Type type);
00103     static QString currentThemeName();
00104     static QStringList themeList();
00105     static void setTheme(const QString &name);
00106     static void setTheme(const SoundTheme &theme);
00107 signals:
00108     void currentThemeChanged(const QString &themeName);
00109 private:
00110     Sound();
00111 };
00112 
00113 }
00114 
00115 #endif // SOUND_H
00116