Kill DeclarativeQtCameraNotifications
[harmattan/cameraplus] / declarative / sounds.h
1 // -*- c++ -*-
2
3 /*!
4  * This file is part of CameraPlus.
5  *
6  * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21  */
22
23 #ifndef SOUNDS_H
24 #define SOUNDS_H
25
26 #include <QObject>
27 #include <canberra.h>
28
29 class QDBusServiceWatcher;
30 class ContextProperty;
31
32 class Sounds : public QObject {
33   Q_OBJECT
34
35   Q_PROPERTY(bool mute READ isMuted WRITE setMuted NOTIFY muteChanged);
36   Q_PROPERTY(QString imageCaptureStart READ imageCaptureStart WRITE setImageCaptureStart NOTIFY imageCaptureStartChanged);
37   Q_PROPERTY(QString imageCaptureEnd READ imageCaptureEnd WRITE setImageCaptureEnd NOTIFY imageCaptureEndChanged);
38   Q_PROPERTY(QString videoRecordingStart READ videoRecordingStart WRITE setVideoRecordingStart NOTIFY videoRecordingStartChanged);
39   Q_PROPERTY(QString videoRecordingEnd READ videoRecordingEnd WRITE setVideoRecordingEnd NOTIFY videoRecordingEndChanged);
40   Q_PROPERTY(QString autoFocusAcquired READ autoFocusAcquired WRITE setAutoFocusAcquired NOTIFY autoFocusAcquiredChanged);
41   Q_PROPERTY(Volume volume READ volume WRITE setVolume NOTIFY volumeChanged);
42   Q_ENUMS(Volume);
43
44 public:
45   Sounds(QObject *parent = 0);
46   ~Sounds();
47
48   typedef enum {
49     VolumeLow,
50     VolumeHigh,
51   } Volume;
52
53   void playImageCaptureStartedSound();
54   void playImageCaptureEndedSound();
55   void playVideoRecordingStartedSound();
56   void playVideoRecordingEndedSound();
57   void playAutoFocusAcquiredSound();
58
59   bool isMuted() const;
60   void setMuted(bool mute);
61
62   Volume volume() const;
63   void setVolume(const Volume& volume);
64
65   void reload();
66
67   QString imageCaptureStart() const;
68   void setImageCaptureStart(const QString& path);
69
70   QString imageCaptureEnd() const;
71   void setImageCaptureEnd(const QString& path);
72
73   QString videoRecordingStart() const;
74   void setVideoRecordingStart(const QString& path);
75
76   QString videoRecordingEnd() const;
77   void setVideoRecordingEnd(const QString& path);
78
79   QString autoFocusAcquired() const;
80   void setAutoFocusAcquired(const QString& path);
81
82 signals:
83   void muteChanged();
84   void volumeChanged();
85   void imageCaptureStartChanged();
86   void imageCaptureEndChanged();
87   void videoRecordingStartChanged();
88   void videoRecordingEndChanged();
89   void autoFocusAcquiredChanged();
90
91 private slots:
92   void serviceOwnerChanged(const QString& serviceName, const QString& oldOwner,
93                            const QString& newOwner);
94   void audioConnectionChanged();
95
96 private:
97   void cache(const QString& path, const char *id);
98   void play(const char *id);
99   void playAndBlock(const char *id);
100
101   bool m_muted;
102   ca_context *m_ctx;
103   QDBusServiceWatcher *m_watcher;
104   ContextProperty *m_audioRoute;
105   QString m_volume;
106   QString m_imageCaptureStart;
107   QString m_imageCaptureEnd;
108   QString m_videoRecordingStart;
109   QString m_videoRecordingEnd;
110   QString m_autoFocusAcquired;
111 };
112
113 #endif /* SOUNDS_H */