1
/****************************************************************************
3
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4
** All rights reserved.
5
** Contact: Nokia Corporation (qt-info@nokia.com)
7
** This file is part of the Qt Mobility Components.
9
** $QT_BEGIN_LICENSE:LGPL$
11
** Licensees holding valid Qt Commercial licenses may use this file in
12
** accordance with the Qt Commercial License Agreement provided with
13
** the Software or, alternatively, in accordance with the terms
14
** contained in a written agreement between you and Nokia.
16
** GNU Lesser General Public License Usage
17
** Alternatively, this file may be used under the terms of the GNU Lesser
18
** General Public License version 2.1 as published by the Free Software
19
** Foundation and appearing in the file LICENSE.LGPL included in the
20
** packaging of this file. Please review the following information to
21
** ensure the GNU Lesser General Public License version 2.1 requirements
22
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24
** In addition, as a special exception, Nokia gives you certain additional
25
** rights. These rights are described in the Nokia Qt LGPL Exception
26
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28
** GNU General Public License Usage
29
** Alternatively, this file may be used under the terms of the GNU
30
** General Public License version 3.0 as published by the Free Software
31
** Foundation and appearing in the file LICENSE.GPL included in the
32
** packaging of this file. Please review the following information to
33
** ensure the GNU General Public License version 3.0 requirements will be
34
** met: http://www.gnu.org/copyleft/gpl.html.
36
** If you are unsure which license is appropriate for your use, please
37
** contact the sales department at qt-sales@nokia.com.
40
****************************************************************************/
42
#include <QtCore/QtPlugin>
43
#include <QtCore/QCoreApplication>
46
#include "qfeedback.h"
48
Q_EXPORT_PLUGIN2(feedback_mmk, QFeedbackMMK)
50
QFeedbackMMK::QFeedbackMMK() : QObject(qApp)
54
QFeedbackMMK::~QFeedbackMMK()
56
foreach(FeedbackInfo fi, mEffects.values()) {
57
delete fi.soundEffect;
61
void QFeedbackMMK::setLoaded(QFeedbackFileEffect *effect, bool load)
66
// See if we have seen this effect before
67
FeedbackInfo fi = mEffects.value(effect);
70
// Well.. we might already have an effect, since we don't create them until
73
// We've already loaded?
77
// We've started a load, they must just be impatient
78
// Pushing this elevator button does nothing..
82
fi.soundEffect = new QSoundEffect(this);
83
connect(fi.soundEffect, SIGNAL(loadedChanged()), this, SLOT(soundEffectLoaded()));
84
fi.soundEffect->setSource(effect->source());
85
mEffects.insert(effect, fi);
86
mEffectMap.insert(fi.soundEffect, effect);
92
mEffectMap.remove(fi.soundEffect);
93
delete fi.soundEffect;
95
mEffects.remove(effect);
99
void QFeedbackMMK::setEffectState(QFeedbackFileEffect *effect, QFeedbackEffect::State state)
101
FeedbackInfo fi = mEffects.value(effect);
104
case QFeedbackEffect::Stopped:
106
Q_ASSERT(fi.soundEffect);
107
fi.soundEffect->stop();
112
case QFeedbackEffect::Paused:
113
// Well, we can't pause, really
114
reportError(effect, QFeedbackEffect::UnknownError);
117
case QFeedbackEffect::Running:
119
// We're already playing.
120
} else if (fi.soundEffect){
121
fi.soundEffect->play();
130
QFeedbackEffect::State QFeedbackMMK::effectState(const QFeedbackFileEffect *effect)
132
FeedbackInfo fi = mEffects.value(effect);
134
if (fi.soundEffect) {
136
return QFeedbackEffect::Running;
138
return QFeedbackEffect::Stopped; // No idle?
139
return QFeedbackEffect::Loading;
141
return QFeedbackEffect::Stopped;
144
int QFeedbackMMK::effectDuration(const QFeedbackFileEffect *effect)
147
// XXX This isn't supported by MMK currently
151
QStringList QFeedbackMMK::supportedMimeTypes()
153
return QSoundEffect::supportedMimeTypes();
156
void QFeedbackMMK::soundEffectLoaded()
158
QSoundEffect* se = qobject_cast<QSoundEffect*>(sender());
160
// Hmm, now look up the right sound effect
161
QFeedbackFileEffect* fe = mEffectMap.value(se);
164
reportLoadFinished(fe, se->isLoaded());