2 * This file is part of CameraPlus.
4 * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library 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 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "notificationscontainer.h"
22 #include "qtcamdevice.h"
23 #include "qtcamnotifications.h"
24 #include "notifications.h"
26 NotificationsContainer::NotificationsContainer(QObject *parent) :
27 QObject(parent), m_dev(0), m_notifications(0) {
31 NotificationsContainer::~NotificationsContainer() {
34 QMutexLocker locker(&m_mutex);
38 void NotificationsContainer::setDevice(QtCamDevice *dev) {
40 QtCamNotifications *n = m_dev->notifications();
41 QObject::disconnect(n, SIGNAL(imageCaptureStarted()), this, SLOT(imageCaptureStarted()));
42 QObject::disconnect(n, SIGNAL(imageCaptureEnded()), this, SLOT(imageCaptureEnded()));
43 QObject::disconnect(n, SIGNAL(videoRecordingStarted()), this, SLOT(videoRecordingStarted()));
44 QObject::disconnect(n, SIGNAL(videoRecordingEnded()), this, SLOT(videoRecordingEnded()));
50 QtCamNotifications *n = m_dev->notifications();
51 QObject::connect(n, SIGNAL(imageCaptureStarted()),
52 this, SLOT(imageCaptureStarted()), Qt::DirectConnection);
53 QObject::connect(n, SIGNAL(imageCaptureEnded()),
54 this, SLOT(imageCaptureEnded()), Qt::DirectConnection);
55 QObject::connect(n, SIGNAL(videoRecordingStarted()),
56 this, SLOT(videoRecordingStarted()), Qt::DirectConnection);
57 QObject::connect(n, SIGNAL(videoRecordingEnded()),
58 this, SLOT(videoRecordingEnded()), Qt::DirectConnection);
62 Notifications *NotificationsContainer::notifications() const {
63 return m_notifications;
66 bool NotificationsContainer::setNotifications(Notifications *notifications) {
67 QMutexLocker lock(&m_mutex);
69 if (m_notifications != notifications) {
70 m_notifications = notifications;
77 void NotificationsContainer::imageCaptureStarted() {
78 QMutexLocker l(&m_mutex);
80 if (m_notifications) {
81 m_notifications->imageCaptureStarted();
85 void NotificationsContainer::imageCaptureEnded() {
86 QMutexLocker l(&m_mutex);
88 if (m_notifications) {
89 m_notifications->imageCaptureEnded();
93 void NotificationsContainer::videoRecordingStarted() {
94 QMutexLocker l(&m_mutex);
96 if (m_notifications) {
97 m_notifications->videoRecordingStarted();
101 void NotificationsContainer::videoRecordingEnded() {
102 QMutexLocker l(&m_mutex);
104 if (m_notifications) {
105 m_notifications->videoRecordingEnded();