diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2010-01-13 18:55:05 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-01-13 18:55:05 (GMT) |
commit | 7d1e48639d6d3897e66779f22fe02d17d6c38707 (patch) | |
tree | 7abc16568274e1f54c976f890e92d73f7a00160c /src/3rdparty | |
parent | 20e0e7a849d70139f9106f60c78fd0c736ec3c4b (diff) | |
parent | e1b03bac22f87edbbe78eba366966259be6eb0ed (diff) | |
download | Qt-7d1e48639d6d3897e66779f22fe02d17d6c38707.zip Qt-7d1e48639d6d3897e66779f22fe02d17d6c38707.tar.gz Qt-7d1e48639d6d3897e66779f22fe02d17d6c38707.tar.bz2 |
Merge branch '4.6'
Conflicts:
bin/syncqt
doc/src/deployment/deployment.qdoc
src/corelib/io/qfsfileengine_win.cpp
src/corelib/xml/qxmlstream.cpp
src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
tools/assistant/tools/assistant/centralwidget.cpp
tools/linguist/lupdate/main.cpp
Diffstat (limited to 'src/3rdparty')
42 files changed, 1614 insertions, 242 deletions
diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp index e7ef9b2..132eb79 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.cpp @@ -37,18 +37,24 @@ using namespace Phonon::MMF; AbstractAudioEffect::AbstractAudioEffect(QObject *parent, const QList<EffectParameter> ¶ms) - : MediaNode::MediaNode(parent) - , m_player(0) + : MediaNode(parent) , m_params(params) + , m_player(0) { + } -QList<EffectParameter> AbstractAudioEffect::parameters() const +QList<Phonon::EffectParameter> AbstractAudioEffect::parameters() const { - return m_params; + // Convert from QList<MMF::EffectParameter> to QList<Phonon::EffectParameter> + QList<Phonon::EffectParameter> result; + EffectParameter param; + foreach (param, m_params) + result += param; + return result; } -QVariant AbstractAudioEffect::parameterValue(const EffectParameter &queriedParam) const +QVariant AbstractAudioEffect::parameterValue(const Phonon::EffectParameter &queriedParam) const { const QVariant &val = m_values.value(queriedParam.id()); @@ -58,13 +64,31 @@ QVariant AbstractAudioEffect::parameterValue(const EffectParameter &queriedParam return val; } -void AbstractAudioEffect::setParameterValue(const EffectParameter ¶m, +void AbstractAudioEffect::setParameterValue(const Phonon::EffectParameter ¶m, const QVariant &newValue) { m_values.insert(param.id(), newValue); - parameterChanged(param.id(), newValue); - // TODO: handle audio effect errors - TRAP_IGNORE(m_effect->ApplyL()); + + if (m_effect.data()) { + const EffectParameter& internalParam = internalParameter(param.id()); + int err = parameterChanged(internalParam, newValue); + // TODO: handle audio effect errors + Q_UNUSED(err); + } +} + +void AbstractAudioEffect::abstractPlayerChanged(AbstractPlayer *player) +{ + m_player = qobject_cast<AbstractMediaPlayer *>(player); + m_effect.reset(); +} + +void AbstractAudioEffect::stateChanged(Phonon::State newState, + Phonon::State oldState) +{ + if (Phonon::LoadingState == oldState + && Phonon::LoadingState != newState) + createEffect(); } void AbstractAudioEffect::connectMediaObject(MediaObject *mediaObject) @@ -72,26 +96,99 @@ void AbstractAudioEffect::connectMediaObject(MediaObject *mediaObject) Q_ASSERT_X(!m_player, Q_FUNC_INFO, "Player already connected"); Q_ASSERT_X(!m_effect.data(), Q_FUNC_INFO, "Effect already created"); - AbstractMediaPlayer *const player = - qobject_cast<AbstractMediaPlayer *>(mediaObject->abstractPlayer()); + abstractPlayerChanged(mediaObject->abstractPlayer()); + + connect(mediaObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), + SLOT(stateChanged(Phonon::State, Phonon::State))); + + connect(mediaObject, SIGNAL(abstractPlayerChanged(AbstractPlayer *)), + SLOT(abstractPlayerChanged(AbstractPlayer *))); + + if (mediaObject->state() != Phonon::LoadingState) + createEffect(); +} + +void AbstractAudioEffect::disconnectMediaObject(MediaObject *mediaObject) +{ + mediaObject->disconnect(this); + abstractPlayerChanged(0); +} - if (player) { - m_player = player; +void AbstractAudioEffect::setEnabled(bool enabled) +{ + TInt err = KErrNone; - if (AudioPlayer *audioPlayer = qobject_cast<AudioPlayer *>(player)) { - connectAudioPlayer(audioPlayer->nativePlayer()); - applyParameters(); - // TODO: handle audio effect errors - TRAP_IGNORE(m_effect->EnableL()); + if (enabled) + // TODO: handle audio effect errors + TRAP(err, m_effect->EnableL()) + else + // TODO: handle audio effect errors + TRAP(err, m_effect->DisableL()) + + Q_UNUSED(err); +} + +void AbstractAudioEffect::createEffect() +{ + Q_ASSERT_X(m_player, Q_FUNC_INFO, "Invalid media player pointer"); + + if (AudioPlayer *audioPlayer = qobject_cast<AudioPlayer *>(m_player)) { + createEffect(audioPlayer->nativePlayer()); + } + + if (m_effect.data()) { + EffectParameter param; + int err = 0; + foreach (param, m_params) { + const QVariant value = parameterValue(param); + err = parameterChanged(param, value); } + Q_UNUSED(err) } } -void AbstractAudioEffect::disconnectMediaObject(MediaObject * /*mediaObject*/) +const MMF::EffectParameter& AbstractAudioEffect::internalParameter(int id) const { - m_player = 0; - m_effect.reset(); + const EffectParameter *result = 0; + for (int i=0; i<m_params.count() && !result; ++i) { + if (m_params[i].id() == id) + result = &m_params[i]; + } + Q_ASSERT_X(result, Q_FUNC_INFO, "Parameter not found"); + return *result; +} + +int AbstractAudioEffect::parameterChanged(const EffectParameter ¶m, + const QVariant &value) +{ + int err = 0; + + switch (param.id()) { + case ParameterEnable: + setEnabled(value.toBool()); + break; + default: + { + const EffectParameter& internalParam = internalParameter(param.id()); + err = effectParameterChanged(internalParam, value); + } + break; + } + + if (!err) + TRAP(err, m_effect->ApplyL()); + + return err; } +int AbstractAudioEffect::effectParameterChanged( + const EffectParameter ¶m, const QVariant &value) +{ + // Default implementation + Q_ASSERT_X(false, Q_FUNC_INFO, "Effect has no parameters"); + return 0; +} + + QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/abstractaudioeffect.h b/src/3rdparty/phonon/mmf/abstractaudioeffect.h index 6f74a73..9878472 100644 --- a/src/3rdparty/phonon/mmf/abstractaudioeffect.h +++ b/src/3rdparty/phonon/mmf/abstractaudioeffect.h @@ -24,18 +24,21 @@ along with this library. If not, see <http://www.gnu.org/licenses/>. #include <AudioEffectBase.h> #include <Phonon/EffectInterface> -#include <Phonon/EffectParameter> #include "audioplayer.h" +#include "effectparameter.h" #include "mmf_medianode.h" #include "mmf_videoplayer.h" +class CMdaAudioOutputStream; + QT_BEGIN_NAMESPACE namespace Phonon { namespace MMF { +class AbstractPlayer; class AbstractMediaPlayer; /** @@ -63,46 +66,73 @@ public: AbstractAudioEffect(QObject *parent, const QList<EffectParameter> ¶ms); - virtual QList<EffectParameter> parameters() const; - virtual QVariant parameterValue(const EffectParameter ¶m) const; - virtual void setParameterValue(const EffectParameter &, + // Phonon::EffectInterface + virtual QList<Phonon::EffectParameter> parameters() const; + virtual QVariant parameterValue(const Phonon::EffectParameter ¶m) const; + virtual void setParameterValue(const Phonon::EffectParameter &, const QVariant &newValue); - enum Type + // Parameters which are shared by all effects + enum CommonParameters { - EffectAudioEqualizer = 1, - EffectBassBoost, - EffectDistanceAttenuation, - EffectEnvironmentalReverb, - EffectListenerOrientation, - EffectLoudness, - EffectSourceOrientation, - EffectStereoWidening + ParameterEnable = 0, + ParameterBase // must be last entry in enum }; +public Q_SLOTS: + void abstractPlayerChanged(AbstractPlayer *player); + void stateChanged(Phonon::State newState, + Phonon::State oldState); + protected: // MediaNode void connectMediaObject(MediaObject *mediaObject); void disconnectMediaObject(MediaObject *mediaObject); - virtual void connectAudioPlayer(AudioPlayer::NativePlayer *player) = 0; - virtual void applyParameters() = 0; + virtual void createEffect(AudioPlayer::NativePlayer *player) = 0; - virtual void parameterChanged(const int id, - const QVariant &value) = 0; + // Effect-specific parameter changed + virtual int effectParameterChanged(const EffectParameter ¶m, + const QVariant &value); + +private: + void createEffect(); + void setEnabled(bool enabled); + const EffectParameter& internalParameter(int id) const; + int parameterChanged(const EffectParameter ¶m, + const QVariant &value); protected: QScopedPointer<CAudioEffect> m_effect; private: - AbstractMediaPlayer * m_player; const QList<EffectParameter> m_params; + AbstractMediaPlayer * m_player; QHash<int, QVariant> m_values; }; } } + +// Macro for defining functions which depend on the native class name +// for each of the effects. Using this reduces repetition of boilerplate +// in the implementations of the backend effect nodes. + +#define PHONON_MMF_DEFINE_EFFECT_FUNCTIONS(Effect) \ + \ +void Effect##::createEffect(AudioPlayer::NativePlayer *player) \ +{ \ + C##Effect *ptr = 0; \ + QT_TRAP_THROWING(ptr = C##Effect::NewL(*player)); \ + m_effect.reset(ptr); \ +} \ + \ +C##Effect* Effect::concreteEffect() \ +{ \ + return static_cast<C##Effect *>(m_effect.data()); \ +} + QT_END_NAMESPACE #endif diff --git a/src/3rdparty/phonon/mmf/abstractplayer.h b/src/3rdparty/phonon/mmf/abstractplayer.h index 40ad7f8..dbcbe63 100644 --- a/src/3rdparty/phonon/mmf/abstractplayer.h +++ b/src/3rdparty/phonon/mmf/abstractplayer.h @@ -106,8 +106,8 @@ Q_SIGNALS: void finished(); void tick(qint64 time); void bufferStatus(int percentFilled); - void stateChanged(Phonon::State oldState, - Phonon::State newState); + void stateChanged(Phonon::State newState, + Phonon::State oldState); void metaDataChanged(const QMultiMap<QString, QString>& metaData); void aboutToFinish(); void prefinishMarkReached(qint32 remaining); diff --git a/src/3rdparty/phonon/mmf/audioequalizer.cpp b/src/3rdparty/phonon/mmf/audioequalizer.cpp index c2936c5..1d2bbd4 100644 --- a/src/3rdparty/phonon/mmf/audioequalizer.cpp +++ b/src/3rdparty/phonon/mmf/audioequalizer.cpp @@ -28,80 +28,79 @@ using namespace Phonon::MMF; \internal */ -AudioEqualizer::AudioEqualizer(QObject *parent) : AbstractAudioEffect::AbstractAudioEffect(parent, createParams()) +// Define functions which depend on concrete native effect class name +PHONON_MMF_DEFINE_EFFECT_FUNCTIONS(AudioEqualizer) + +AudioEqualizer::AudioEqualizer(QObject *parent, const QList<EffectParameter>& parameters) + : AbstractAudioEffect::AbstractAudioEffect(parent, parameters) { + } -void AudioEqualizer::parameterChanged(const int pid, +int AudioEqualizer::effectParameterChanged(const EffectParameter ¶m, const QVariant &value) { - if (m_effect.data()) { - const int band = pid; - const int level = value.toInt(); - setBandLevel(band, level); - } -} + const int band = param.id() - ParameterBase + 1; -void AudioEqualizer::connectAudioPlayer(AudioPlayer::NativePlayer *player) -{ - CAudioEqualizer *ptr = 0; - QT_TRAP_THROWING(ptr = CAudioEqualizer::NewL(*player)); - m_effect.reset(ptr); -} + const qreal externalLevel = value.toReal(); + const int internalLevel = param.toInternalValue(externalLevel); -void AudioEqualizer::applyParameters() -{ - if (m_effect.data()) { - EffectParameter param; - foreach (param, parameters()) { - const int band = param.id(); - const int level = parameterValue(param).toInt(); - setBandLevel(band, level); - } - } + TRAPD(err, concreteEffect()->SetBandLevelL(band, internalLevel)); + return err; } -void AudioEqualizer::setBandLevel(int band, int level) + +//----------------------------------------------------------------------------- +// Static functions +//----------------------------------------------------------------------------- + +const char* AudioEqualizer::description() { - CAudioEqualizer *const effect = static_cast<CAudioEqualizer *>(m_effect.data()); - // TODO: handle audio effect errors - TRAP_IGNORE(effect->SetBandLevelL(band, level)); + return "Audio equalizer"; } -QList<EffectParameter> AudioEqualizer::createParams() +bool AudioEqualizer::getParameters(CMdaAudioOutputStream *stream, + QList<EffectParameter>& parameters) { - QList<EffectParameter> retval; + bool supported = false; + + QScopedPointer<CAudioEqualizer> effect; + TRAPD(err, effect.reset(CAudioEqualizer::NewL(*stream))); - // We temporarily create an AudioPlayer, and run the effect on it, so - // we can extract the readonly data we need. - AudioPlayer dummyPlayer; + if (KErrNone == err) { + supported = true; - CAudioEqualizer *eqPtr = 0; - QT_TRAP_THROWING(eqPtr = CAudioEqualizer::NewL(*dummyPlayer.nativePlayer())); - QScopedPointer<CAudioEqualizer> e(eqPtr); + TInt32 dbMin; + TInt32 dbMax; + effect->DbLevelLimits(dbMin, dbMax); - TInt32 dbMin; - TInt32 dbMax; - e->DbLevelLimits(dbMin, dbMax); + const int bandCount = effect->NumberOfBands(); - const int bandCount = e->NumberOfBands(); + for (int i = 0; i < bandCount; ++i) { + // For some reason, band IDs are 1-based, as opposed to the + // 0-based indices used in just about other Symbian API...! + const int band = i + 1; - for (int i = 0; i < bandCount; ++i) { - const qint32 hz = e->CenterFrequency(i); + const qint32 hz = effect->CenterFrequency(band); - const qint32 defVol = e->BandLevel(i); + // We pass a floating-point parameter range of -1.0 to +1.0 for + // each band in order to work around a limitation in + // Phonon::EffectWidget. See documentation of EffectParameter + // for more details. + EffectParameter param( + /* parameterId */ ParameterBase + i, + /* name */ tr("%1 Hz").arg(hz), + /* hints */ EffectParameter::LogarithmicHint, + /* defaultValue */ QVariant(qreal(0.0)), + /* minimumValue */ QVariant(qreal(-1.0)), + /* maximumValue */ QVariant(qreal(+1.0))); - retval.append(EffectParameter(i, - tr("Frequency band, %1 Hz").arg(hz), - EffectParameter::LogarithmicHint, - QVariant(qint32(defVol)), - QVariant(qint32(dbMin)), - QVariant(qint32(dbMax)), - QVariantList(), - QString())); + param.setInternalRange(dbMin, dbMax); + parameters.append(param); + } } - return retval; + return supported; } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/audioequalizer.h b/src/3rdparty/phonon/mmf/audioequalizer.h index 10fe9ad..9c3770a 100644 --- a/src/3rdparty/phonon/mmf/audioequalizer.h +++ b/src/3rdparty/phonon/mmf/audioequalizer.h @@ -21,6 +21,8 @@ along with this library. If not, see <http://www.gnu.org/licenses/>. #include "abstractaudioeffect.h" +class CAudioEqualizer; + QT_BEGIN_NAMESPACE namespace Phonon @@ -39,19 +41,21 @@ class AudioEqualizer : public AbstractAudioEffect { Q_OBJECT public: - AudioEqualizer(QObject *parent); + AudioEqualizer(QObject *parent, const QList<EffectParameter> ¶meters); + + // Static interface required by EffectFactory + static const char* description(); + static bool getParameters(CMdaAudioOutputStream *stream, + QList<EffectParameter>& parameters); protected: // AbstractAudioEffect - virtual void connectAudioPlayer(AudioPlayer::NativePlayer *player); - virtual void applyParameters(); - virtual void parameterChanged(const int id, const QVariant &value); - -private: - void setBandLevel(int band, int level); + virtual void createEffect(AudioPlayer::NativePlayer *player); + virtual int effectParameterChanged(const EffectParameter ¶m, + const QVariant &value); private: - static QList<EffectParameter> createParams(); + CAudioEqualizer *concreteEffect(); }; } diff --git a/src/3rdparty/phonon/mmf/backend.cpp b/src/3rdparty/phonon/mmf/backend.cpp index 0c07f66..3568a49 100644 --- a/src/3rdparty/phonon/mmf/backend.cpp +++ b/src/3rdparty/phonon/mmf/backend.cpp @@ -45,6 +45,7 @@ using namespace Phonon::MMF; Backend::Backend(QObject *parent) : QObject(parent) , m_ancestorMoveMonitor(new AncestorMoveMonitor(this)) + , m_effectFactory(new EffectFactory(this)) { TRACE_CONTEXT(Backend::Backend, EBackend); TRACE_ENTRY_0(); @@ -81,9 +82,9 @@ QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const { Q_ASSERT(args.count() == 1); Q_ASSERT(args.first().type() == QVariant::Int); - const AbstractAudioEffect::Type effect = AbstractAudioEffect::Type(args.first().toInt()); - - return EffectFactory::createAudioEffect(effect, parent); + const EffectFactory::Type type = + static_cast<EffectFactory::Type>(args.first().toInt()); + return m_effectFactory->createAudioEffect(type, parent); } case VideoWidgetClass: result = new VideoWidget(m_ancestorMoveMonitor.data(), qobject_cast<QWidget *>(parent)); @@ -105,7 +106,7 @@ QList<int> Backend::objectDescriptionIndexes(ObjectDescriptionType type) const switch(type) { case EffectType: - retval.append(EffectFactory::effectIndexes()); + retval.append(m_effectFactory->effectIndexes()); break; case AudioOutputDeviceType: // We only have one possible output device, but we need at least @@ -126,7 +127,7 @@ QHash<QByteArray, QVariant> Backend::objectDescriptionProperties(ObjectDescripti switch (type) { case EffectType: - return EffectFactory::audioEffectDescriptions(AbstractAudioEffect::Type(index)); + return m_effectFactory->audioEffectDescriptions(EffectFactory::Type(index)); case AudioOutputDeviceType: return AudioOutput::audioOutputDescription(index); default: diff --git a/src/3rdparty/phonon/mmf/backend.h b/src/3rdparty/phonon/mmf/backend.h index 9e3d3b3..6b85625 100644 --- a/src/3rdparty/phonon/mmf/backend.h +++ b/src/3rdparty/phonon/mmf/backend.h @@ -20,6 +20,7 @@ along with this library. If not, see <http://www.gnu.org/licenses/>. #define PHONON_MMF_BACKEND_H #include "ancestormovemonitor.h" +#include "effectfactory.h" #include <Phonon/MediaSource> #include <Phonon/BackendInterface> @@ -53,6 +54,7 @@ Q_SIGNALS: private: QScopedPointer<AncestorMoveMonitor> m_ancestorMoveMonitor; + QScopedPointer<EffectFactory> m_effectFactory; }; } diff --git a/src/3rdparty/phonon/mmf/bassboost.cpp b/src/3rdparty/phonon/mmf/bassboost.cpp index ae96b45..c7af939 100644 --- a/src/3rdparty/phonon/mmf/bassboost.cpp +++ b/src/3rdparty/phonon/mmf/bassboost.cpp @@ -24,31 +24,34 @@ QT_BEGIN_NAMESPACE using namespace Phonon; using namespace Phonon::MMF; +// Define functions which depend on concrete native effect class name +PHONON_MMF_DEFINE_EFFECT_FUNCTIONS(BassBoost) + /*! \class MMF::BassBoost \internal */ -BassBoost::BassBoost(QObject *parent) : AbstractAudioEffect::AbstractAudioEffect(parent, - QList<EffectParameter>()) +BassBoost::BassBoost(QObject *parent, const QList<EffectParameter> ¶meters) + : AbstractAudioEffect::AbstractAudioEffect(parent, parameters) { -} -void BassBoost::parameterChanged(const int, - const QVariant &) -{ - Q_ASSERT_X(false, Q_FUNC_INFO, "BassBoost has not parameters"); } -void BassBoost::connectAudioPlayer(AudioPlayer::NativePlayer *player) +//----------------------------------------------------------------------------- +// Static functions +//----------------------------------------------------------------------------- + +const char* BassBoost::description() { - CBassBoost *ptr = 0; - QT_TRAP_THROWING(ptr = CBassBoost::NewL(*player)); - m_effect.reset(ptr); + return "Bass boost"; } -void BassBoost::applyParameters() +bool BassBoost::getParameters(CMdaAudioOutputStream *stream, + QList<EffectParameter> ¶meters) { - // No parameters to apply + QScopedPointer<CBassBoost> effect; + TRAPD(err, effect.reset(CBassBoost::NewL(*stream))); + return (KErrNone == err); } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/bassboost.h b/src/3rdparty/phonon/mmf/bassboost.h index 4ad0a6c..fc40e21 100644 --- a/src/3rdparty/phonon/mmf/bassboost.h +++ b/src/3rdparty/phonon/mmf/bassboost.h @@ -21,6 +21,8 @@ along with this library. If not, see <http://www.gnu.org/licenses/>. #include "abstractaudioeffect.h" +class CBassBoost; + QT_BEGIN_NAMESPACE namespace Phonon @@ -28,22 +30,25 @@ namespace Phonon namespace MMF { /** - * @short An "bass boost" effect. - * - * The documentation does not say what "bass boost" is, neither has it anykind - * of setting. It's an on or off thing. + * @short A "bass boost" effect. */ class BassBoost : public AbstractAudioEffect { Q_OBJECT public: - BassBoost(QObject *parent); + BassBoost(QObject *parent, const QList<EffectParameter> ¶meters); + + // Static interface required by EffectFactory + static const char* description(); + static bool getParameters(CMdaAudioOutputStream *stream, + QList<EffectParameter>& parameters); protected: // AbstractAudioEffect - virtual void connectAudioPlayer(AudioPlayer::NativePlayer *player); - virtual void applyParameters(); - virtual void parameterChanged(const int id, const QVariant &value); + virtual void createEffect(AudioPlayer::NativePlayer *player); + +private: + CBassBoost *concreteEffect(); }; } diff --git a/src/3rdparty/phonon/mmf/effectfactory.cpp b/src/3rdparty/phonon/mmf/effectfactory.cpp index cc94367..c5e33d5 100644 --- a/src/3rdparty/phonon/mmf/effectfactory.cpp +++ b/src/3rdparty/phonon/mmf/effectfactory.cpp @@ -19,19 +19,13 @@ along with this library. If not, see <http://www.gnu.org/licenses/>. #include <QObject> #include <QCoreApplication> -#include <AudioEqualizerBase.h> -#include <BassBoostBase.h> -#include <DistanceAttenuationBase.h> -#include <DopplerBase.h> -#include <EnvironmentalReverbBase.h> -#include <ListenerOrientationBase.h> -#include <LocationBase.h> -#include <LoudnessBase.h> -#include <SourceOrientationBase.h> -#include <StereoWideningBase.h> +#include <mdaaudiooutputstream.h> #include "audioequalizer.h" #include "bassboost.h" +#include "environmentalreverb.h" +#include "loudness.h" +#include "stereowidening.h" #include "effectfactory.h" @@ -44,111 +38,176 @@ using namespace Phonon::MMF; \internal */ -QHash<QByteArray, QVariant> EffectFactory::constructEffectDescription(const QString &name, - const QString &description) +EffectFactory::EffectFactory(QObject *parent) + : QObject(parent) + , m_initialized(false) { - QHash<QByteArray, QVariant> retval; - retval.insert("name", name); - retval.insert("description", description); - retval.insert("available", true); - - return retval; } - -QHash<QByteArray, QVariant> EffectFactory::audioEffectDescriptions(AbstractAudioEffect::Type type) +EffectFactory::~EffectFactory() { - switch (type) - { - case AbstractAudioEffect::EffectAudioEqualizer: - return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Audio Equalizer"), "Audio equalizer."); - case AbstractAudioEffect::EffectBassBoost: - return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Bass Boost"), "Bass boost."); - case AbstractAudioEffect::EffectDistanceAttenuation: - return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Distance Attenuation"), "Distance Attenuation."); - case AbstractAudioEffect::EffectEnvironmentalReverb: - return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Environmental Reverb"), "Environmental Reverb."); - case AbstractAudioEffect::EffectListenerOrientation: - return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Environmental Reverb"), "Environmental Reverb."); - case AbstractAudioEffect::EffectLoudness: - return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Loudness"), "Loudness."); - case AbstractAudioEffect::EffectSourceOrientation: - return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Source Orientation"), "Source Orientation."); - case AbstractAudioEffect::EffectStereoWidening: - return constructEffectDescription(QCoreApplication::translate("Phonon::MMF::EffectFactory", "Stereo Widening"), "Stereo Widening."); - } - Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown effect type."); - return QHash<QByteArray, QVariant>(); } -AbstractAudioEffect *EffectFactory::createAudioEffect(AbstractAudioEffect::Type type, +//----------------------------------------------------------------------------- +// Public functions +//----------------------------------------------------------------------------- + +AbstractAudioEffect *EffectFactory::createAudioEffect(Type type, QObject *parent) { + // Lazily initialize + if (!m_initialized) + initialize(); + Q_ASSERT(parent); + const QList<EffectParameter>& parameters = data(type).m_parameters; + + AbstractAudioEffect *effect = 0; + switch (type) { - case AbstractAudioEffect::EffectBassBoost: - return new BassBoost(parent); - case AbstractAudioEffect::EffectAudioEqualizer: - return new AudioEqualizer(parent); - case AbstractAudioEffect::EffectDistanceAttenuation: - case AbstractAudioEffect::EffectEnvironmentalReverb: - case AbstractAudioEffect::EffectListenerOrientation: - case AbstractAudioEffect::EffectLoudness: - case AbstractAudioEffect::EffectSourceOrientation: - case AbstractAudioEffect::EffectStereoWidening: - ; + case TypeBassBoost: + effect = new BassBoost(parent, parameters); + break; + case TypeAudioEqualizer: + effect = new AudioEqualizer(parent, parameters); + break; + case TypeEnvironmentalReverb: + effect = new EnvironmentalReverb(parent, parameters); + break; + case TypeLoudness: + effect = new Loudness(parent, parameters); + break; + case TypeStereoWidening: + effect = new StereoWidening(parent, parameters); + break; + + // Not implemented + case TypeDistanceAttenuation: + case TypeListenerOrientation: + case TypeSourceOrientation: + // Fall through + default: + Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown effect"); } - Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown effect."); - return 0; + return effect; } -template<typename TEffect> -bool isEffectSupported() +QHash<QByteArray, QVariant> EffectFactory::audioEffectDescriptions(Type type) { - AudioPlayer audioPlayer; - - QScopedPointer<TEffect> eff; - TRAPD(errorCode, eff.reset(TEffect::NewL(*audioPlayer.nativePlayer()))); + // Lazily initialize + if (!m_initialized) + initialize(); - return errorCode != KErrNone; + return data(type).m_descriptions; } QList<int> EffectFactory::effectIndexes() { - QList<int> retval; + // Lazily initialize + if (!m_initialized) + initialize(); - if (isEffectSupported<CAudioEqualizer>()) - retval.append(AbstractAudioEffect::EffectAudioEqualizer); + QList<int> result; - if (isEffectSupported<CBassBoost>()) - retval.append(AbstractAudioEffect::EffectBassBoost); + QHash<Type, EffectData>::const_iterator i = m_effectData.begin(); + for ( ; i != m_effectData.end(); ++i) + if (i.value().m_supported) + result.append(i.key()); - /* We haven't implemented these yet. - if (isEffectSupported<CDistanceAttenuation>()) - retval.append(AbstractAudioEffect::EffectDistanceAttenuation); + return result; +} - if (isEffectSupported<CEnvironmentalReverb>()) - retval.append(AbstractAudioEffect::EffectEnvironmentalReverb); +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- - if (isEffectSupported<CLoudness>()) - retval.append(AbstractAudioEffect::EffectLoudness); +#define INITIALIZE_EFFECT(Effect) \ + { \ + EffectData data = getData<Effect>(); \ + m_effectData.insert(Type##Effect, data); \ + } - if (isEffectSupported<CListenerOrientation>()) - retval.append(AbstractAudioEffect::EffectListenerOrientation); +void EffectFactory::initialize() +{ + Q_ASSERT_X(!m_initialized, Q_FUNC_INFO, "Already initialized"); - if (isEffectSupported<CSourceOrientation>()) - retval.append(AbstractAudioEffect::EffectSourceOrientation); + INITIALIZE_EFFECT(AudioEqualizer) + INITIALIZE_EFFECT(BassBoost) + INITIALIZE_EFFECT(EnvironmentalReverb) + INITIALIZE_EFFECT(Loudness) + INITIALIZE_EFFECT(StereoWidening) - if (isEffectSupported<CStereoWidening>()) - retval.append(AbstractAudioEffect::EffectStereoWidening); - */ + m_initialized = true; +} + +// This class is just a wrapper which allows us to instantiate a +// CMdaAudioOutputStream object. This is done in order to allow the +// effects API to query the DevSound implementation, to discover +// which effects are supported and what parameters they take. +// Ideally, we would use CMMFDevSound directly, but this class is not +// available in the public S60 SDK. +class OutputStreamFactory : public MMdaAudioOutputStreamCallback +{ +public: + CMdaAudioOutputStream* create() + { + CMdaAudioOutputStream* stream = 0; + QT_TRAP_THROWING(stream = CMdaAudioOutputStream::NewL(*this)); + return stream; + } +private: + void MaoscOpenComplete(TInt /*aError*/) { } + void MaoscBufferCopied(TInt /*aError*/, const TDesC8& /*aBuffer*/) { } + void MaoscPlayComplete(TInt /*aError*/) { } +}; + +template<typename BackendNode> +EffectFactory::EffectData EffectFactory::getData() +{ + EffectData data; + + // Create a temporary CMdaAudioOutputStream object, so that the effects + // API can query DevSound to discover which effects are supported. + OutputStreamFactory streamFactory; + QScopedPointer<CMdaAudioOutputStream> stream(streamFactory.create()); + + EffectParameter param( + /* parameterId */ AbstractAudioEffect::ParameterEnable, + /* name */ tr("Enabled"), + /* hints */ EffectParameter::ToggledHint, + /* defaultValue */ QVariant(bool(true))); + data.m_parameters.append(param); + + if (data.m_supported = BackendNode::getParameters + (stream.data(), data.m_parameters)) { + const QString description = QCoreApplication::translate + ("Phonon::MMF::EffectFactory", BackendNode::description()); + data.m_descriptions.insert("name", description); + data.m_descriptions.insert("description", description); + data.m_descriptions.insert("available", true); + } + + // Sanity check to ensure that all parameter IDs are unique + QSet<int> ids; + foreach (param, data.m_parameters) { + Q_ASSERT_X(ids.find(param.id()) == ids.end(), Q_FUNC_INFO, + "Parameter list contains duplicates"); + ids.insert(param.id()); + } - return retval; + return data; +} + +const EffectFactory::EffectData& EffectFactory::data(Type type) const +{ + QHash<Type, EffectData>::const_iterator i = m_effectData.find(type); + Q_ASSERT_X(i != m_effectData.end(), Q_FUNC_INFO, "Effect data not found"); + return i.value(); } QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/effectfactory.h b/src/3rdparty/phonon/mmf/effectfactory.h index e83ad15..dd4b58d 100644 --- a/src/3rdparty/phonon/mmf/effectfactory.h +++ b/src/3rdparty/phonon/mmf/effectfactory.h @@ -20,6 +20,7 @@ along with this library. If not, see <http://www.gnu.org/licenses/>. #define PHONON_MMF_EFFECTFACTORY_H #include "abstractaudioeffect.h" +#include "effectparameter.h" QT_BEGIN_NAMESPACE @@ -31,14 +32,30 @@ namespace MMF /** * @short Contains utility functions related to effects. */ -class EffectFactory +class EffectFactory : public QObject { + Q_OBJECT + public: + EffectFactory(QObject *parent); + ~EffectFactory(); + + enum Type + { + TypeAudioEqualizer = 0 + , TypeBassBoost + , TypeDistanceAttenuation + , TypeEnvironmentalReverb + , TypeListenerOrientation + , TypeLoudness + , TypeSourceOrientation + , TypeStereoWidening + }; + /** * @short Creates an audio effect of type @p type. */ - static AbstractAudioEffect *createAudioEffect(AbstractAudioEffect::Type type, - QObject *parent); + AbstractAudioEffect *createAudioEffect(Type type, QObject *parent); /** * @short Return the properties for effect @p type. @@ -46,7 +63,7 @@ public: * This handles the effects for * BackendInterface::objectDescriptionProperties(). */ - static QHash<QByteArray, QVariant> audioEffectDescriptions(AbstractAudioEffect::Type type); + QHash<QByteArray, QVariant> audioEffectDescriptions(Type type); /** * @short Returns the indexes for the supported effects. @@ -54,19 +71,27 @@ public: * This handles the effects for * BackendInterface::objectDescriptionIndexes(). */ - static QList<int> effectIndexes(); + QList<int> effectIndexes(); private: - static inline QHash<QByteArray, QVariant> constructEffectDescription(const QString &name, - const QString &description); + void initialize(); + + struct EffectData + { + bool m_supported; + QHash<QByteArray, QVariant> m_descriptions; + QList<EffectParameter> m_parameters; + }; + + template<typename BackendNode> EffectData getData(); + const EffectData& data(Type type) const; + +private: + bool m_initialized; + QHash<Type, EffectData> m_effectData; - /** - * This class is not supposed to be instantiated, so disable - * the default constructor. - */ - inline EffectFactory(); - Q_DISABLE_COPY(EffectFactory) }; + } } diff --git a/src/3rdparty/phonon/mmf/effectparameter.cpp b/src/3rdparty/phonon/mmf/effectparameter.cpp new file mode 100644 index 0000000..17c1315 --- /dev/null +++ b/src/3rdparty/phonon/mmf/effectparameter.cpp @@ -0,0 +1,71 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#include "effectparameter.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +/*! \class MMF::EffectParameter + \internal +*/ + +MMF::EffectParameter::EffectParameter() + : m_hasInternalRange(false) +{ + +} + +MMF::EffectParameter::EffectParameter( + int parameterId, const QString &name, Hints hints, + const QVariant &defaultValue, const QVariant &min, + const QVariant &max, const QVariantList &values, + const QString &description) + : Phonon::EffectParameter(parameterId, name, hints, defaultValue, + min, max, values, description) + , m_hasInternalRange(false) +{ + +} + +void MMF::EffectParameter::setInternalRange(qint32 min, qint32 max) +{ + Q_ASSERT_X(max >= min, Q_FUNC_INFO, "Invalid range"); + m_internalRange = QPair<qint32, qint32>(min, max); + m_hasInternalRange = true; +} + +qint32 MMF::EffectParameter::toInternalValue(qreal external) const +{ + Q_ASSERT_X(m_hasInternalRange, Q_FUNC_INFO, "Does not have internal range"); + const qint32 range = m_internalRange.second - m_internalRange.first; + return m_internalRange.first + ((1.0 + external) / 2) * range; +} + +qreal MMF::EffectParameter::toExternalValue + (qint32 value, qint32 min, qint32 max) +{ + Q_ASSERT_X(max >= min, Q_FUNC_INFO, "Invalid range"); + const qint32 range = max - min; + return range == 0 ? 0.0 : ((2.0 * value - min) / range) - 1.0; +} + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/effectparameter.h b/src/3rdparty/phonon/mmf/effectparameter.h new file mode 100644 index 0000000..27cc018 --- /dev/null +++ b/src/3rdparty/phonon/mmf/effectparameter.h @@ -0,0 +1,74 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_EFFECTPARAMETER_H +#define PHONON_MMF_EFFECTPARAMETER_H + +#include <Phonon/EffectParameter> + +QT_BEGIN_NAMESPACE + +namespace Phonon +{ +namespace MMF +{ + +/** + * @short Parameter value for an audio effect + * + * The base class is extended in order to work around a shortcoming + * in Phonon::EffectWidget. This widget only displays sliders for + * parameters with numeric values if the variant type of the parameter + * is QReal and the range is exactly -1.0 to +1.0; otherwise, a + * spinbox is used to set numeric parameters. This is rather + * inconvenient for many effects, such as the audio equalizer, for + * which a slider is a much more natural UI control. + * + * For many such parameters, we therefore report the type to be QReal + * and the range to be -1.0 to +1.0. This class stores the actual + * integer range for the parameter, and provides the toInternalValue + * function for converting between the client-side floating point + * value and the internal integer value. + */ +class EffectParameter : public Phonon::EffectParameter +{ +public: + EffectParameter(); + EffectParameter(int parameterId, const QString &name, Hints hints, + const QVariant &defaultValue, const QVariant &min = QVariant(), + const QVariant &max = QVariant(), const QVariantList &values = QVariantList(), + const QString &description = QString()); + + void setInternalRange(qint32 min, qint32 max); + qint32 toInternalValue(qreal external) const; + + static qreal toExternalValue(qint32 value, qint32 min, qint32 max); + +private: + bool m_hasInternalRange; + QPair<qint32, qint32> m_internalRange; + +}; + +} +} + +QT_END_NAMESPACE + +#endif + diff --git a/src/3rdparty/phonon/mmf/environmentalreverb.cpp b/src/3rdparty/phonon/mmf/environmentalreverb.cpp new file mode 100644 index 0000000..89f8d60 --- /dev/null +++ b/src/3rdparty/phonon/mmf/environmentalreverb.cpp @@ -0,0 +1,201 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#include <EnvironmentalReverbBase.h> +#include "environmentalreverb.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +/*! \class MMF::EnvironmentalReverb + \internal +*/ + +// Define functions which depend on concrete native effect class name +PHONON_MMF_DEFINE_EFFECT_FUNCTIONS(EnvironmentalReverb) + +enum Parameters +{ + DecayHFRatio = AbstractAudioEffect::ParameterBase, + DecayTime, + Density, + Diffusion, + ReflectionsDelay, + ReflectionsLevel, + ReverbDelay, + ReverbLevel, + RoomHFLevel, + RoomLevel +}; + +EnvironmentalReverb::EnvironmentalReverb(QObject *parent, const QList<EffectParameter>& parameters) + : AbstractAudioEffect::AbstractAudioEffect(parent, parameters) +{ + +} + +int EnvironmentalReverb::effectParameterChanged(const EffectParameter ¶m, + const QVariant &value) +{ + const qreal externalLevel = value.toReal(); + const int internalLevel = param.toInternalValue(externalLevel); + + TInt err = 0; + + switch(param.id()) { + case DecayHFRatio: + TRAP(err, concreteEffect()->SetDecayHFRatioL(internalLevel)); + break; + case DecayTime: + TRAP(err, concreteEffect()->SetDecayTimeL(internalLevel)); + break; + case Density: + TRAP(err, concreteEffect()->SetDensityL(internalLevel)); + break; + case Diffusion: + TRAP(err, concreteEffect()->SetDiffusionL(internalLevel)); + break; + case ReflectionsDelay: + TRAP(err, concreteEffect()->SetReflectionsDelayL(internalLevel)); + break; + case ReflectionsLevel: + TRAP(err, concreteEffect()->SetReflectionsLevelL(internalLevel)); + break; + case ReverbDelay: + TRAP(err, concreteEffect()->SetReverbDelayL(internalLevel)); + break; + case ReverbLevel: + TRAP(err, concreteEffect()->SetReverbLevelL(internalLevel)); + break; + case RoomHFLevel: + TRAP(err, concreteEffect()->SetRoomHFLevelL(internalLevel)); + break; + case RoomLevel: + TRAP(err, concreteEffect()->SetRoomLevelL(internalLevel)); + break; + default: + Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown parameter"); + } + + return err; +} + + +//----------------------------------------------------------------------------- +// Static functions +//----------------------------------------------------------------------------- + +const char* EnvironmentalReverb::description() +{ + return "Reverb"; +} + +// Internal helper function +Phonon::MMF::EffectParameter createParameter(int id, const QString &name, + int defaultValue, int minValue, int maxValue, + Phonon::EffectParameter::Hint hint = Phonon::EffectParameter::IntegerHint) +{ + const qreal externalDefaultValue = + Phonon::MMF::EffectParameter::toExternalValue + (defaultValue, minValue, maxValue); + + Phonon::MMF::EffectParameter param(id, name, hint, + /* defaultValue */ QVariant(externalDefaultValue), + /* minimumValue */ QVariant(qreal(-1.0)), + /* maximumValue */ QVariant(qreal(+1.0))); + + param.setInternalRange(minValue, maxValue); + return param; +} + +bool EnvironmentalReverb::getParameters(CMdaAudioOutputStream *stream, + QList<EffectParameter>& parameters) +{ + bool supported = false; + + QScopedPointer<CEnvironmentalReverb> effect; + TRAPD(err, effect.reset(CEnvironmentalReverb::NewL(*stream))); + + if (KErrNone == err) { + supported = true; + + TInt32 min, max; + TUint32 umin, umax; + + // DecayHFRatio + effect->DecayHFRatioRange(umin, umax); + parameters.append(createParameter( + DecayHFRatio, tr("Decay HF ratio (%)"), effect->DecayHFRatio(), + umin, umax)); + + // DecayTime + effect->DecayTimeRange(umin, umax); + parameters.append(createParameter( + DecayTime, tr("Decay time (ms)"), effect->DecayTime(), + umin, umax)); + + // Density + parameters.append(createParameter( + Density, tr("Density (%)"), effect->Density(), 0, 100)); + + // Diffusion + parameters.append(createParameter( + Diffusion, tr("Diffusion (%)"), effect->Diffusion(), 0, 100)); + + // ReflectionsDelay + parameters.append(createParameter( + ReflectionsDelay, tr("Reflections delay (ms)"), + effect->ReflectionsDelay(), 0, effect->ReflectionsDelayMax())); + + // ReflectionsLevel + effect->ReflectionLevelRange(min, max); + parameters.append(createParameter( + ReflectionsLevel, tr("Reflections level (mB)"), + effect->ReflectionsLevel(), + min, max, EffectParameter::LogarithmicHint)); + + // ReverbDelay + parameters.append(createParameter( + ReverbDelay, tr("Reverb delay (ms)"), effect->ReverbDelay(), + 0, effect->ReverbDelayMax())); + + // ReverbLevel + effect->ReverbLevelRange(min, max); + parameters.append(createParameter( + ReverbLevel, tr("Reverb level (mB)"), effect->ReverbLevel(), + min, max, EffectParameter::LogarithmicHint)); + + // RoomHFLevel + effect->RoomHFLevelRange(min, max); + parameters.append(createParameter( + RoomHFLevel, tr("Room HF level"), effect->RoomHFLevel(), + min, max)); + + // RoomLevel + effect->RoomLevelRange(min, max); + parameters.append(createParameter( + RoomLevel, tr("Room level (mB)"), effect->RoomLevel(), + min, max, EffectParameter::LogarithmicHint)); + } + + return supported; +} + +QT_END_NAMESPACE diff --git a/src/3rdparty/phonon/mmf/environmentalreverb.h b/src/3rdparty/phonon/mmf/environmentalreverb.h new file mode 100644 index 0000000..eab68c6 --- /dev/null +++ b/src/3rdparty/phonon/mmf/environmentalreverb.h @@ -0,0 +1,62 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_ENVIRONMENTALREVERB_H +#define PHONON_MMF_ENVIRONMENTALREVERB_H + +#include "abstractaudioeffect.h" + +class CEnvironmentalReverb; + +QT_BEGIN_NAMESPACE + +namespace Phonon +{ +namespace MMF +{ +/** + * @short A reverb effect. + */ +class EnvironmentalReverb : public AbstractAudioEffect +{ + Q_OBJECT +public: + EnvironmentalReverb(QObject *parent, const QList<EffectParameter>& parameters); + + // Static interface required by EffectFactory + static const char* description(); + static bool getParameters(CMdaAudioOutputStream *stream, + QList<EffectParameter>& parameters); + +protected: + // AbstractAudioEffect + virtual void createEffect(AudioPlayer::NativePlayer *player); + virtual int effectParameterChanged(const EffectParameter ¶m, + const QVariant &value); + +private: + CEnvironmentalReverb *concreteEffect(); + +}; +} +} + +QT_END_NAMESPACE + +#endif + diff --git a/src/3rdparty/phonon/mmf/loudness.cpp b/src/3rdparty/phonon/mmf/loudness.cpp new file mode 100644 index 0000000..1079a35 --- /dev/null +++ b/src/3rdparty/phonon/mmf/loudness.cpp @@ -0,0 +1,58 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#include <LoudnessBase.h> +#include "loudness.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +// Define functions which depend on concrete native effect class name +PHONON_MMF_DEFINE_EFFECT_FUNCTIONS(Loudness) + +/*! \class MMF::Loudness + \internal +*/ + +Loudness::Loudness(QObject *parent, const QList<EffectParameter>& parameters) + : AbstractAudioEffect::AbstractAudioEffect(parent, parameters) +{ + +} + +//----------------------------------------------------------------------------- +// Static functions +//----------------------------------------------------------------------------- + +const char* Loudness::description() +{ + return "Loudness"; +} + +bool Loudness::getParameters(CMdaAudioOutputStream *stream, + QList<EffectParameter> ¶meters) +{ + QScopedPointer<CLoudness> effect; + TRAPD(err, effect.reset(CLoudness::NewL(*stream))); + return (KErrNone == err); +} + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/loudness.h b/src/3rdparty/phonon/mmf/loudness.h new file mode 100644 index 0000000..a688a67 --- /dev/null +++ b/src/3rdparty/phonon/mmf/loudness.h @@ -0,0 +1,60 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_LOUDNESS_H +#define PHONON_MMF_LOUDNESS_H + +#include "abstractaudioeffect.h" + +class CLoudness; + +QT_BEGIN_NAMESPACE + +namespace Phonon +{ +namespace MMF +{ +/** + * @short A "loudness" effect. + */ +class Loudness : public AbstractAudioEffect +{ + Q_OBJECT +public: + Loudness(QObject *parent, const QList<EffectParameter>& parameters); + + // Static interface required by EffectFactory + static const char* description(); + static bool getParameters(CMdaAudioOutputStream *stream, + QList<EffectParameter>& parameters); + +protected: + // AbstractAudioEffect + virtual void createEffect(AudioPlayer::NativePlayer *player); + +private: + CLoudness *concreteEffect(); + +}; +} +} + +QT_END_NAMESPACE + +#endif + diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 4653fee..9744774 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -297,7 +297,10 @@ void MMF::MediaObject::createPlayer(const MediaSource &source) break; } + if (oldPlayer) + emit abstractPlayerChanged(0); m_player.reset(newPlayer); + emit abstractPlayerChanged(newPlayer); if (oldPlayerHasVideo != hasVideo()) { emit hasVideoChanged(hasVideo()); diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index 668b953..c87d755 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -92,6 +92,7 @@ public Q_SLOTS: void switchToNextSource(); Q_SIGNALS: + void abstractPlayerChanged(AbstractPlayer *player); void totalTimeChanged(qint64 length); void hasVideoChanged(bool hasVideo); void seekableChanged(bool seekable); @@ -101,8 +102,8 @@ Q_SIGNALS: // TODO: emit metaDataChanged from MediaObject void metaDataChanged(const QMultiMap<QString, QString>& metaData); void currentSourceChanged(const MediaSource& source); - void stateChanged(Phonon::State oldState, - Phonon::State newState); + void stateChanged(Phonon::State newState, + Phonon::State oldState); void finished(); void tick(qint64 time); diff --git a/src/3rdparty/phonon/mmf/stereowidening.cpp b/src/3rdparty/phonon/mmf/stereowidening.cpp new file mode 100644 index 0000000..f90651b --- /dev/null +++ b/src/3rdparty/phonon/mmf/stereowidening.cpp @@ -0,0 +1,93 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#include <StereoWideningBase.h> +#include "stereowidening.h" + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +// Define functions which depend on concrete native effect class name +PHONON_MMF_DEFINE_EFFECT_FUNCTIONS(StereoWidening) + +/*! \class MMF::StereoWidening + \internal +*/ + +StereoWidening::StereoWidening(QObject *parent, const QList<EffectParameter>& parameters) + : AbstractAudioEffect::AbstractAudioEffect(parent, parameters) +{ + +} + +int StereoWidening::parameterChanged(const EffectParameter ¶m, + const QVariant &value) +{ + Q_ASSERT_X(param.id() == ParameterBase, Q_FUNC_INFO, "Invalid parameter ID"); + + const qreal externalLevel = value.toReal(); + const int internalLevel = param.toInternalValue(externalLevel); + + TRAPD(err, concreteEffect()->SetStereoWideningLevelL(internalLevel)); + + return err; +} + +//----------------------------------------------------------------------------- +// Static functions +//----------------------------------------------------------------------------- + +const char* StereoWidening::description() +{ + return "Stereo widening"; +} + +bool StereoWidening::getParameters(CMdaAudioOutputStream *stream, + QList<EffectParameter> ¶meters) +{ + bool supported = false; + + QScopedPointer<CStereoWidening> effect; + TRAPD(err, effect.reset(CStereoWidening::NewL(*stream))); + + if (KErrNone == err) { + supported = true; + + const qreal defaultValue = + Phonon::MMF::EffectParameter::toExternalValue + (effect->StereoWideningLevel(), 0, 100); + + EffectParameter param( + /* parameterId */ ParameterBase, + /* name */ tr("Level (%)"), + /* hints */ EffectParameter::IntegerHint, + /* defaultValue */ QVariant(defaultValue), + /* minimumValue */ QVariant(qreal(-1.0)), + /* maximumValue */ QVariant(qreal(+1.0))); + + param.setInternalRange(0, 100); + parameters.append(param); + } + + return supported; +} + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/stereowidening.h b/src/3rdparty/phonon/mmf/stereowidening.h new file mode 100644 index 0000000..c967e37 --- /dev/null +++ b/src/3rdparty/phonon/mmf/stereowidening.h @@ -0,0 +1,62 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_STEREOWIDENING_H +#define PHONON_MMF_STEREOWIDENING_H + +#include "abstractaudioeffect.h" + +class CStereoWidening; + +QT_BEGIN_NAMESPACE + +namespace Phonon +{ +namespace MMF +{ +/** + * @short A "bass boost" effect. + */ +class StereoWidening : public AbstractAudioEffect +{ + Q_OBJECT +public: + StereoWidening(QObject *parent, const QList<EffectParameter>& parameters); + + // Static interface required by EffectFactory + static const char* description(); + static bool getParameters(CMdaAudioOutputStream *stream, + QList<EffectParameter>& parameters); + +protected: + // AbstractAudioEffect + virtual void createEffect(AudioPlayer::NativePlayer *player); + virtual int parameterChanged(const EffectParameter ¶m, + const QVariant &value); + +private: + CStereoWidening *concreteEffect(); + +}; +} +} + +QT_END_NAMESPACE + +#endif + diff --git a/src/3rdparty/phonon/phonon/effectwidget.cpp b/src/3rdparty/phonon/phonon/effectwidget.cpp index 2334d7f..a2fe50f 100644 --- a/src/3rdparty/phonon/phonon/effectwidget.cpp +++ b/src/3rdparty/phonon/phonon/effectwidget.cpp @@ -15,7 +15,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Lesser General Public License along with this library. If not, see <http://www.gnu.org/licenses/>. */ @@ -151,7 +151,7 @@ void EffectWidgetPrivate::autogenerateUi() bool minValueOk = false; bool maxValueOk = false; const int minValue = para.minimumValue().toInt(&minValueOk); - const int maxValue = para.minimumValue().toInt(&maxValueOk); + const int maxValue = para.maximumValue().toInt(&maxValueOk); sb->setRange(minValueOk ? minValue : DEFAULT_MIN_INT, maxValueOk ? maxValue : DEFAULT_MAX_INT); sb->setValue(value.toInt()); diff --git a/src/3rdparty/webkit/JavaScriptCore/API/JSClassRef.cpp b/src/3rdparty/webkit/JavaScriptCore/API/JSClassRef.cpp index afde7ce..3785bab 100644 --- a/src/3rdparty/webkit/JavaScriptCore/API/JSClassRef.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/API/JSClassRef.cpp @@ -61,8 +61,8 @@ OpaqueJSClass::OpaqueJSClass(const JSClassDefinition* definition, OpaqueJSClass* if (const JSStaticValue* staticValue = definition->staticValues) { m_staticValues = new OpaqueJSClassStaticValuesTable(); while (staticValue->name) { - m_staticValues->add(UString::Rep::createFromUTF8(staticValue->name), - new StaticValueEntry(staticValue->getProperty, staticValue->setProperty, staticValue->attributes)); + StaticValueEntry* e = new StaticValueEntry(staticValue->getProperty, staticValue->setProperty, staticValue->attributes); + m_staticValues->add(UString::Rep::createFromUTF8(staticValue->name), e); ++staticValue; } } @@ -70,8 +70,8 @@ OpaqueJSClass::OpaqueJSClass(const JSClassDefinition* definition, OpaqueJSClass* if (const JSStaticFunction* staticFunction = definition->staticFunctions) { m_staticFunctions = new OpaqueJSClassStaticFunctionsTable(); while (staticFunction->name) { - m_staticFunctions->add(UString::Rep::createFromUTF8(staticFunction->name), - new StaticFunctionEntry(staticFunction->callAsFunction, staticFunction->attributes)); + StaticFunctionEntry* e = new StaticFunctionEntry(staticFunction->callAsFunction, staticFunction->attributes); + m_staticFunctions->add(UString::Rep::createFromUTF8(staticFunction->name), e); ++staticFunction; } } @@ -149,8 +149,9 @@ OpaqueJSClassContextData::OpaqueJSClassContextData(OpaqueJSClass* jsClass) OpaqueJSClassStaticValuesTable::const_iterator end = jsClass->m_staticValues->end(); for (OpaqueJSClassStaticValuesTable::const_iterator it = jsClass->m_staticValues->begin(); it != end; ++it) { ASSERT(!it->first->identifierTable()); - staticValues->add(UString::Rep::createCopying(it->first->data(), it->first->size()), - new StaticValueEntry(it->second->getProperty, it->second->setProperty, it->second->attributes)); + StaticValueEntry* e = new StaticValueEntry(it->second->getProperty, it->second->setProperty, it->second->attributes); + staticValues->add(UString::Rep::createCopying(it->first->data(), it->first->size()), e); + } } else @@ -162,8 +163,8 @@ OpaqueJSClassContextData::OpaqueJSClassContextData(OpaqueJSClass* jsClass) OpaqueJSClassStaticFunctionsTable::const_iterator end = jsClass->m_staticFunctions->end(); for (OpaqueJSClassStaticFunctionsTable::const_iterator it = jsClass->m_staticFunctions->begin(); it != end; ++it) { ASSERT(!it->first->identifierTable()); - staticFunctions->add(UString::Rep::createCopying(it->first->data(), it->first->size()), - new StaticFunctionEntry(it->second->callAsFunction, it->second->attributes)); + StaticFunctionEntry* e = new StaticFunctionEntry(it->second->callAsFunction, it->second->attributes); + staticFunctions->add(UString::Rep::createCopying(it->first->data(), it->first->size()), e); } } else diff --git a/src/3rdparty/webkit/JavaScriptCore/ChangeLog b/src/3rdparty/webkit/JavaScriptCore/ChangeLog index a559d9b..e292418 100644 --- a/src/3rdparty/webkit/JavaScriptCore/ChangeLog +++ b/src/3rdparty/webkit/JavaScriptCore/ChangeLog @@ -1,3 +1,34 @@ +2010-01-07 Norbert Leser <norbert.leser@nokia.com> + + Reviewed by NOBODY (OOPS!). + + RVCT compiler with "-Otime -O3" optimization tries to optimize out + inline new'ed pointers that are passed as arguments. + Proposed patch assigns new'ed pointer explicitly outside function call. + + * API/JSClassRef.cpp: + (OpaqueJSClass::OpaqueJSClass): + (OpaqueJSClassContextData::OpaqueJSClassContextData): + +2010-01-07 Norbert Leser <norbert.leser@nokia.com> + + Reviewed by NOBODY (OOPS!). + + Added time-based optimization and increased optimization level to O3, + conditionally for COMPILER(RVCT), + for increasing performance of JavaScript execution. + (Default settings are Ospace and O2) + + * runtime/Structure.h: + +2009-11-19 Thiago Macieira <thiago.macieira@nokia.com> + + Reviewed by Simon Hausmann. + + Build fix for 32-bit Sparc machines: these machines are big-endian. + + * wtf/Platform.h: + 2009-12-08 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk> Reviewed by Darin Adler. diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h b/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h index f355c53..ecdd997 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/Structure.h @@ -45,6 +45,12 @@ #define DUMP_PROPERTYMAP_STATS 0 #endif +#if COMPILER(RVCT) +#pragma arm +#pragma Otime +#pragma O3 +#endif + namespace JSC { class MarkStack; diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h b/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h index 3e1093b..4a008cc 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h @@ -218,6 +218,16 @@ #define WTF_PLATFORM_BIG_ENDIAN 1 #endif +/* PLATFORM(SPARC32) */ +#if defined(__sparc) && !defined(__arch64__) || defined(__sparcv8) +#define WTF_PLATFORM_SPARC32 1 +#define WTF_PLATFORM_BIG_ENDIAN 1 +#endif + +#if PLATFORM(SPARC32) || PLATFORM(SPARC64) +#define WTF_PLATFORM_SPARC +#endif + /* PLATFORM(PPC64) */ #if defined(__ppc64__) \ || defined(__PPC64__) diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 70913ca..b69ac98 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -8,4 +8,4 @@ The commit imported was from the and has the sha1 checksum - 865abd2871c801c1d3d0f4eebd985b2daab89ebe + bd6591b4acaf2172ab05702153ef539c0ac89cbb diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index e72293d..ab5b131 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,58 @@ +2010-01-12 Jakub Wieczorek <faw217@gmail.com> + + Reviewed by Adam Barth. + + [Qt] XSL stylesheets can load documents from a different origin + + https://bugs.webkit.org/show_bug.cgi?id=33423 + + * xml/XSLTProcessorQt.cpp: + (WebCore::XSLTUriResolver::XSLTUriResolver): + (WebCore::XSLTUriResolver::resolve): + (WebCore::XSLTProcessor::transformToString): + +2010-01-07 Yael Aharon <yael.aharon@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Allow the application to override online/offline network status + https://bugs.webkit.org/show_bug.cgi?id=32684 + + Added API to NetworkStateNotifier for forcing network status. + + * platform/network/NetworkStateNotifier.h: + * platform/network/qt/NetworkStateNotifierPrivate.h: + * platform/network/qt/NetworkStateNotifierQt.cpp: + (WebCore::NetworkStateNotifierPrivate::NetworkStateNotifierPrivate): + (WebCore::NetworkStateNotifierPrivate::onlineStateChanged): + (WebCore::NetworkStateNotifierPrivate::networkAccessPermissionChanged): + (WebCore::NetworkStateNotifier::updateState): + (WebCore::NetworkStateNotifier::NetworkStateNotifier): + (WebCore::NetworkStateNotifier::setNetworkAccessAllowed): + +2010-01-07 Simon Hausmann <simon.hausmann@nokia.com> + + Reviewed by Tor Arne Vestbø. + + [Qt] Fix linkage against Qt mobility API bearer management module + + Use the documented .pro file syntax to link against the correct + library and (more importantly) get the include paths correct. + + * WebCore.pro: + +2010-01-07 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Reviewed by NOBODY (OOPS!). + + [RVCT] ACID3 test crash + https://bugs.webkit.org/show_bug.cgi?id=33280 + + Workaround developed by Yongjun Zhang. + + * dom/Element.cpp: + (WebCore::Element::setAttribute): + 2010-01-06 Simon Hausmann <simon.hausmann@nokia.com> Unreviewed trivial Qt build fix. diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index be64e3b..3eba696 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -2876,8 +2876,8 @@ contains(DEFINES, ENABLE_QT_BEARER=1) { SOURCES += \ platform/network/qt/NetworkStateNotifierQt.cpp - LIBS += -lQtBearer - + CONFIG += mobility + MOBILITY += bearer } contains(DEFINES, ENABLE_SVG=1) { diff --git a/src/3rdparty/webkit/WebCore/dom/Element.cpp b/src/3rdparty/webkit/WebCore/dom/Element.cpp index 6924773..0692999 100644 --- a/src/3rdparty/webkit/WebCore/dom/Element.cpp +++ b/src/3rdparty/webkit/WebCore/dom/Element.cpp @@ -516,7 +516,11 @@ void Element::setAttribute(const AtomicString& name, const AtomicString& value, return; } +#if COMPILER(RVCT) + const AtomicString localName = shouldIgnoreAttributeCase(this) ? name.lower() : name; +#else const AtomicString& localName = shouldIgnoreAttributeCase(this) ? name.lower() : name; +#endif // allocate attributemap if necessary Attribute* old = attributes(false)->getAttributeItem(localName, false); diff --git a/src/3rdparty/webkit/WebCore/platform/network/NetworkStateNotifier.h b/src/3rdparty/webkit/WebCore/platform/network/NetworkStateNotifier.h index f8c5654..700a062 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/NetworkStateNotifier.h +++ b/src/3rdparty/webkit/WebCore/platform/network/NetworkStateNotifier.h @@ -56,7 +56,11 @@ public: void setNetworkStateChangedFunction(void (*)()); bool onLine() const { return m_isOnLine; } - + +#if (PLATFORM(QT) && ENABLE(QT_BEARER)) + void setNetworkAccessAllowed(bool); +#endif + private: bool m_isOnLine; void (*m_networkStateChangedFunction)(); diff --git a/src/3rdparty/webkit/WebCore/platform/network/qt/NetworkStateNotifierPrivate.h b/src/3rdparty/webkit/WebCore/platform/network/qt/NetworkStateNotifierPrivate.h index 7af6392..536b06a 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/qt/NetworkStateNotifierPrivate.h +++ b/src/3rdparty/webkit/WebCore/platform/network/qt/NetworkStateNotifierPrivate.h @@ -37,10 +37,12 @@ public: ~NetworkStateNotifierPrivate(); public slots: void onlineStateChanged(bool); + void networkAccessPermissionChanged(bool); public: QtMobility::QNetworkConfigurationManager* m_configurationManager; bool m_online; + bool m_networkAccessAllowed; NetworkStateNotifier* m_notifier; }; diff --git a/src/3rdparty/webkit/WebCore/platform/network/qt/NetworkStateNotifierQt.cpp b/src/3rdparty/webkit/WebCore/platform/network/qt/NetworkStateNotifierQt.cpp index f74398b..e694264 100644 --- a/src/3rdparty/webkit/WebCore/platform/network/qt/NetworkStateNotifierQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/network/qt/NetworkStateNotifierQt.cpp @@ -30,6 +30,7 @@ namespace WebCore { NetworkStateNotifierPrivate::NetworkStateNotifierPrivate(NetworkStateNotifier* notifier) : m_configurationManager(new QNetworkConfigurationManager()) , m_online(m_configurationManager->isOnline()) + , m_networkAccessAllowed(true) , m_notifier(notifier) { Q_ASSERT(notifier); @@ -42,7 +43,18 @@ void NetworkStateNotifierPrivate::onlineStateChanged(bool isOnline) return; m_online = isOnline; - m_notifier->updateState(); + if (m_networkAccessAllowed) + m_notifier->updateState(); +} + +void NetworkStateNotifierPrivate::networkAccessPermissionChanged(bool isAllowed) +{ + if (isAllowed == m_networkAccessAllowed) + return; + + m_networkAccessAllowed = isAllowed; + if (m_online) + m_notifier->updateState(); } NetworkStateNotifierPrivate::~NetworkStateNotifierPrivate() @@ -52,10 +64,10 @@ NetworkStateNotifierPrivate::~NetworkStateNotifierPrivate() void NetworkStateNotifier::updateState() { - if (m_isOnLine == p->m_online) + if (m_isOnLine == (p->m_online && p->m_networkAccessAllowed)) return; - m_isOnLine = p->m_online; + m_isOnLine = p->m_online && p->m_networkAccessAllowed; if (m_networkStateChangedFunction) m_networkStateChangedFunction(); } @@ -65,7 +77,12 @@ NetworkStateNotifier::NetworkStateNotifier() , m_networkStateChangedFunction(0) { p = new NetworkStateNotifierPrivate(this); - m_isOnLine = p->m_online; + m_isOnLine = p->m_online && p->m_networkAccessAllowed; +} + +void NetworkStateNotifier::setNetworkAccessAllowed(bool isAllowed) +{ + p->networkAccessPermissionChanged(isAllowed); } } // namespace WebCore diff --git a/src/3rdparty/webkit/WebCore/xml/XSLTProcessorQt.cpp b/src/3rdparty/webkit/WebCore/xml/XSLTProcessorQt.cpp index 50ee427..3e05ca0 100644 --- a/src/3rdparty/webkit/WebCore/xml/XSLTProcessorQt.cpp +++ b/src/3rdparty/webkit/WebCore/xml/XSLTProcessorQt.cpp @@ -36,6 +36,7 @@ #include <wtf/Vector.h> #include <qabstractmessagehandler.h> +#include <qabstracturiresolver.h> #include <qbuffer.h> #include <qsourcelocation.h> #include <qxmlquery.h> @@ -87,6 +88,31 @@ void XSLTMessageHandler::handleMessage(QtMsgType type, const QString& descriptio sourceLocation.line(), sourceLocation.uri().toString()); } +class XSLTUriResolver : public QAbstractUriResolver { + +public: + XSLTUriResolver(Document* document); + virtual QUrl resolve(const QUrl& relative, const QUrl& baseURI) const; + +private: + Document* m_document; +}; + +XSLTUriResolver::XSLTUriResolver(Document* document) + : QAbstractUriResolver() + , m_document(document) +{ +} + +QUrl XSLTUriResolver::resolve(const QUrl& relative, const QUrl& baseURI) const +{ + QUrl url = baseURI.resolved(relative); + + if (!m_document->frame() || !m_document->securityOrigin()->canRequest(url)) + return QUrl(); + return url; +} + bool XSLTProcessor::transformToString(Node* sourceNode, String&, String& resultString, String&) { bool success = false; @@ -107,6 +133,7 @@ bool XSLTProcessor::transformToString(Node* sourceNode, String&, String& resultS QXmlQuery query(QXmlQuery::XSLT20); XSLTMessageHandler messageHandler(ownerDocument.get()); + XSLTUriResolver uriResolver(ownerDocument.get()); query.setMessageHandler(&messageHandler); XSLTProcessor::ParameterMap::iterator end = m_parameters.end(); @@ -132,6 +159,9 @@ bool XSLTProcessor::transformToString(Node* sourceNode, String&, String& resultS query.setFocus(&inputBuffer); query.setQuery(&styleSheetBuffer, QUrl(stylesheet->href())); + + query.setUriResolver(&uriResolver); + success = query.evaluateTo(&outputBuffer); outputBuffer.reset(); resultString = QString::fromUtf8(outputBuffer.readAll()).trimmed(); diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp index e84b8df..29bde0d 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp @@ -196,6 +196,22 @@ QString QWEBKIT_EXPORT qt_drt_counterValueForElementById(QWebFrame* qFrame, cons return QString(); } +// Suspend active DOM objects in this frame. +void QWEBKIT_EXPORT qt_suspendActiveDOMObjects(QWebFrame* qFrame) +{ + Frame* frame = QWebFramePrivate::core(qFrame); + if (frame->document()) + frame->document()->suspendActiveDOMObjects(); +} + +// Resume active DOM objects in this frame. +void QWEBKIT_EXPORT qt_resumeActiveDOMObjects(QWebFrame* qFrame) +{ + Frame* frame = QWebFramePrivate::core(qFrame); + if (frame->document()) + frame->document()->resumeActiveDOMObjects(); +} + QWebFrameData::QWebFrameData(WebCore::Page* parentPage, WebCore::Frame* parentFrame, WebCore::HTMLFrameOwnerElement* ownerFrameElement, const WebCore::String& frameName) @@ -308,6 +324,45 @@ void QWebFramePrivate::renderPrivate(QPainter *painter, QWebFrame::RenderLayer l } } +static bool webframe_scrollOverflow(WebCore::Frame* frame, int dx, int dy) +{ + if (!frame || !frame->document() || !frame->eventHandler()) + return false; + + Node* node = frame->document()->focusedNode(); + if (!node) + node = frame->document()->elementFromPoint(frame->eventHandler()->currentMousePosition().x(), + frame->eventHandler()->currentMousePosition().y()); + if (!node) + return false; + + RenderObject* renderer = node->renderer(); + if (!renderer) + return false; + + if (renderer->isListBox()) + return false; + + RenderLayer* renderLayer = renderer->enclosingLayer(); + if (!renderLayer) + return false; + + bool scrolledHorizontal = false; + bool scrolledVertical = false; + + if (dx > 0) + scrolledHorizontal = renderLayer->scroll(ScrollRight, ScrollByPixel, dx); + else if (dx < 0) + scrolledHorizontal = renderLayer->scroll(ScrollLeft, ScrollByPixel, qAbs(dx)); + + if (dy > 0) + scrolledVertical = renderLayer->scroll(ScrollDown, ScrollByPixel, dy); + else if (dy < 0) + scrolledVertical = renderLayer->scroll(ScrollUp, ScrollByPixel, qAbs(dy)); + + return (scrolledHorizontal || scrolledVertical); +} + /*! \class QWebFrame \since 4.4 @@ -992,6 +1047,51 @@ void QWebFrame::scroll(int dx, int dy) } /*! + \since 4.7 + \internal + Scrolls nested frames starting at this frame, \a dx pixels to the right + and \a dy pixels downward. Both \a dx and \a dy may be negative. First attempts + to scroll elements with CSS overflow followed by this frame. If this + frame doesn't scroll, attempts to scroll the parent + + \sa QWebFrame::scroll +*/ +bool QWEBKIT_EXPORT qtwebkit_webframe_scrollRecursively(QWebFrame* qFrame, int dx, int dy) +{ + Frame* frame = QWebFramePrivate::core(qFrame); + bool scrolledHorizontal = false; + bool scrolledVertical = false; + bool scrolledOverflow = webframe_scrollOverflow(frame, dx, dy); + + if (!scrolledOverflow) { + if (!frame || !frame->view()) + return false; + + do { + IntSize scrollOffset = frame->view()->scrollOffset(); + IntPoint maxScrollOffset = frame->view()->maximumScrollPosition(); + + if (dx > 0) // scroll right + scrolledHorizontal = scrollOffset.width() < maxScrollOffset.x(); + else if (dx < 0) // scroll left + scrolledHorizontal = scrollOffset.width() > 0; + + if (dy > 0) // scroll down + scrolledVertical = scrollOffset.height() < maxScrollOffset.y(); + else if (dy < 0) //scroll up + scrolledVertical = scrollOffset.height() > 0; + + if (scrolledHorizontal || scrolledVertical) { + frame->view()->scrollBy(IntSize(dx, dy)); + return true; + } + frame = frame->tree()->parent(); + } while (frame && frame->view()); + } + return (scrolledHorizontal || scrolledVertical || scrolledOverflow); +} + +/*! \property QWebFrame::scrollPosition \since 4.5 \brief the position the frame is currently scrolled to. diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe_p.h b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe_p.h index 081e65d..095d134 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebframe_p.h +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebframe_p.h @@ -83,6 +83,8 @@ public: void renderPrivate(QPainter*, QWebFrame::RenderLayer, const QRegion& clip); + bool scrollOverflow(int dx, int dy); + QWebFrame *q; Qt::ScrollBarPolicy horizontalScrollBarPolicy; Qt::ScrollBarPolicy verticalScrollBarPolicy; diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp index b637d04..79ef16f 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp @@ -47,6 +47,17 @@ #include <QUrl> #include <QFileInfo> +#if ENABLE(QT_BEARER) +#include "NetworkStateNotifier.h" +#endif + +void QWEBKIT_EXPORT qt_networkAccessAllowed(bool isAllowed) +{ +#if ENABLE(QT_BEARER) + WebCore::networkStateNotifier().setNetworkAccessAllowed(isAllowed); +#endif +} + class QWebSettingsPrivate { public: QWebSettingsPrivate(WebCore::Settings* wcSettings = 0) diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index 4ab5bfb..357b787 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,3 +1,48 @@ +2009-12-18 Joe Ligman <joseph.ligman@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Add new API to QWebFrame to scrollRecursively starting with any css overflow + then checking current frame and then ancestors + https://bugs.webkit.org/show_bug.cgi?id=32668 + + * Api/qwebframe.cpp: + (QWebFramePrivate::scrollOverflow): + (QWebFrame::scrollRecursively): + * Api/qwebframe.h: + * Api/qwebframe_p.h: + * tests/qwebframe/qwebframe.qrc: + * tests/qwebframe/testiframe.html: Added. + * tests/qwebframe/testiframe2.html: Added. + * tests/qwebframe/tst_qwebframe.cpp: + +2010-01-07 Yael Aharon <yael.aharon@nokia.com> + + Reviewed by Kenneth Rohde Christiansen. + + [Qt] Allow the application to override online/offline network status + https://bugs.webkit.org/show_bug.cgi?id=32684 + + Add a setting so that applications can overide the network status. + Applications that use this setting still need to block network access + through QNAM. + + * Api/qwebsettings.cpp: + (qt_networkAccessAllowed): + +2010-01-07 Yongjun Zhang <yongjun.zhang@nokia.com>, Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] need an API to suspend and resume active Javascript DOM objects. + https://bugs.webkit.org/show_bug.cgi?id=31673 + + Add suspend and resume DOM objects private API to QWebFrame. + + * Api/qwebframe.cpp: + (qt_suspendActiveDOMObjects): + (qt_resumeActiveDOMObjects): + 2009-12-30 Janne Koskinen <janne.p.koskinen@digia.com> Reviewed by Simon Hausmann. diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.qrc b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.qrc index 9615e27..8afa0c1 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.qrc +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/qwebframe.qrc @@ -4,5 +4,7 @@ <file>style.css</file> <file>test1.html</file> <file>test2.html</file> +<file>testiframe.html</file> +<file>testiframe2.html</file> </qresource> </RCC> diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/testiframe.html b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/testiframe.html new file mode 100644 index 0000000..9f3ae85 --- /dev/null +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/testiframe.html @@ -0,0 +1,54 @@ +</html> +<html> +<head> +<title></title> +<style type="text/css"> +<!-- +#header { + background: #0f0; + position: absolute; + top: 0px; + left: 0px; + width: 800px; + height: 100px; +} +#content1 { + background: #ff0; + position: absolute; + top: 101px; + left: 0px; + width: 400px; + height: 400px; + overflow: scroll; +} +#content2 { + background: #ff7; + position: absolute; + top: 101px; + left: 401px; + width: 400px; + height: 400px; +} +#footer { + background: #0f0; + position: absolute; + top: 502px; + left: 0px; + width: 800px; + height: 200px; +} +--> +</style> +</head> +<body> +<div id="header"></div> +<div id="content1">You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible. +You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible. +You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible. +You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible. +You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible. +You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible.</div> +<iframe id="content2" name="control" src="testiframe2.html"> </iframe> +<div id="footer"></div> +</body> +</html>
\ No newline at end of file diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/testiframe2.html b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/testiframe2.html new file mode 100644 index 0000000..1913a89 --- /dev/null +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/testiframe2.html @@ -0,0 +1,21 @@ +</html> +<html> +<head> +<title></title> +<style type="text/css"> +<!-- +#content { + background: #fff; + position: absolute; + top: 0px; + left: 0px; + width: 800px; + height: 800px; +} +--> +</style> +</head> +<body> +<div id="content"> </div> +</body> +</html>
\ No newline at end of file diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp index 8cc7953..609f8b4 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp @@ -606,6 +606,7 @@ private slots: void scrollPosition(); void evaluateWillCauseRepaint(); void qObjectWrapperWithSameIdentity(); + void scrollRecursively(); private: QString evalJS(const QString&s) { @@ -2824,5 +2825,71 @@ void tst_QWebFrame::qObjectWrapperWithSameIdentity() QCOMPARE(mainFrame->toPlainText(), QString("test2")); } +bool QWEBKIT_EXPORT qtwebkit_webframe_scrollRecursively(QWebFrame* qFrame, int dx, int dy); + +void tst_QWebFrame::scrollRecursively() +{ + // The test content is + // a nested frame set + // The main frame scrolls + // and has two children + // an iframe and a div overflow + // both scroll + QWebView webView; + QWebPage* webPage = webView.page(); + QSignalSpy loadSpy(webPage, SIGNAL(loadFinished(bool))); + QUrl url = QUrl("qrc:///testiframe.html"); + webPage->mainFrame()->load(url); + QTRY_COMPARE(loadSpy.count(), 1); + + QList<QWebFrame*> children = webPage->mainFrame()->childFrames(); + QVERIFY(children.count() == 1); + + // 1st test + // call scrollRecursively over mainframe + // verify scrolled + // verify scroll postion changed + QPoint scrollPosition(webPage->mainFrame()->scrollPosition()); + QVERIFY(qtwebkit_webframe_scrollRecursively(webPage->mainFrame(), 10, 10)); + QVERIFY(scrollPosition != webPage->mainFrame()->scrollPosition()); + + // 2nd test + // call scrollRecursively over child iframe + // verify scrolled + // verify child scroll position changed + // verify parent's scroll position did not change + scrollPosition = webPage->mainFrame()->scrollPosition(); + QPoint childScrollPosition = children.at(0)->scrollPosition(); + QVERIFY(qtwebkit_webframe_scrollRecursively(children.at(0), 10, 10)); + QVERIFY(scrollPosition == webPage->mainFrame()->scrollPosition()); + QVERIFY(childScrollPosition != children.at(0)->scrollPosition()); + + // 3rd test + // call scrollRecursively over div overflow + // verify scrolled == true + // verify parent and child frame's scroll postion did not change + QWebElement div = webPage->mainFrame()->documentElement().findFirst("#content1"); + QMouseEvent evpres(QEvent::MouseMove, div.geometry().center(), Qt::NoButton, Qt::NoButton, Qt::NoModifier); + webPage->event(&evpres); + scrollPosition = webPage->mainFrame()->scrollPosition(); + childScrollPosition = children.at(0)->scrollPosition(); + QVERIFY(qtwebkit_webframe_scrollRecursively(webPage->mainFrame(), 5, 5)); + QVERIFY(childScrollPosition == children.at(0)->scrollPosition()); + QVERIFY(scrollPosition == webPage->mainFrame()->scrollPosition()); + + // 4th test + // call scrollRecursively twice over childs iframe + // verify scrolled == true first time + // verify parent's scroll == true second time + // verify parent and childs scroll position changed + childScrollPosition = children.at(0)->scrollPosition(); + QVERIFY(qtwebkit_webframe_scrollRecursively(children.at(0), -10, -10)); + QVERIFY(childScrollPosition != children.at(0)->scrollPosition()); + scrollPosition = webPage->mainFrame()->scrollPosition(); + QVERIFY(qtwebkit_webframe_scrollRecursively(children.at(0), -10, -10)); + QVERIFY(scrollPosition != webPage->mainFrame()->scrollPosition()); + +} + QTEST_MAIN(tst_QWebFrame) #include "tst_qwebframe.moc" |