From 21c4bbf73fa630fa6a385c6bbbbdab173c715496 Mon Sep 17 00:00:00 2001 From: Mikkel Krautz Date: Fri, 28 Jun 2013 23:16:12 +0200 Subject: [PATCH] mumble: remove FileEngine.{cpp,h} and use data URLs for better Qt 5 compatibility. --- src/mumble/FileEngine.cpp | 100 -------------------------------------- src/mumble/FileEngine.h | 64 ------------------------ src/mumble/UserModel.cpp | 14 ++++-- src/mumble/mumble.pro | 4 +- 4 files changed, 11 insertions(+), 171 deletions(-) delete mode 100644 src/mumble/FileEngine.cpp delete mode 100644 src/mumble/FileEngine.h diff --git a/src/mumble/FileEngine.cpp b/src/mumble/FileEngine.cpp deleted file mode 100644 index a5aa87f4f..000000000 --- a/src/mumble/FileEngine.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* Copyright (C) 2005-2011, Thorvald Natvig - - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - Neither the name of the Mumble Developers nor the names of its - contributors may be used to endorse or promote products derived from this - software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "mumble_pch.hpp" - -#include "FileEngine.h" - -#include "ClientUser.h" -#include "Global.h" - -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) // QAbstractFileEngineHandler is private in Qt 5. - -MumbleFileEngineHandler::MumbleFileEngineHandler() : QAbstractFileEngineHandler() { -} - -QAbstractFileEngine *MumbleFileEngineHandler::create(const QString &name) const { - QUrl url(name); - - if (url.scheme() == QLatin1String("memoryblob")) - return new MumbleImageFileEngine(url); - - return NULL; -} - -MumbleImageFileEngine::MumbleImageFileEngine(const QUrl &url) : QAbstractFileEngine(), quUrl(url) { - const QString &domain = url.host(); - qslPath = url.path().split(QLatin1Char('/'), QString::SkipEmptyParts); - - if (domain == QLatin1String("avatar") && (qslPath.size() == 2)) { - - unsigned int session = qslPath.first().toUInt(); - ClientUser *cu = ClientUser::get(session); - - if (cu) - qbData.setData(cu->qbaTexture); - } -} - -bool MumbleImageFileEngine::open(QIODevice::OpenMode om) { - return qbData.open(om); -} - -bool MumbleImageFileEngine::close() { - qbData.close(); - return true; -} - -bool MumbleImageFileEngine::seek(qint64 offset) { - return qbData.seek(offset); -} - -qint64 MumbleImageFileEngine::size() const { - return qbData.size(); -} - -qint64 MumbleImageFileEngine::pos() const { - return qbData.pos(); -} - -qint64 MumbleImageFileEngine::read(char *data, qint64 maxlen) { - return qbData.read(data, maxlen); -} - -QString MumbleImageFileEngine::fileName(QAbstractFileEngine::FileName fn) const { - switch (fn) { - case QAbstractFileEngine::BaseName: - return qslPath.last(); - default: - return quUrl.toString(); - } -} - -#endif diff --git a/src/mumble/FileEngine.h b/src/mumble/FileEngine.h deleted file mode 100644 index c356987ed..000000000 --- a/src/mumble/FileEngine.h +++ /dev/null @@ -1,64 +0,0 @@ -/* Copyright (C) 2005-2011, Thorvald Natvig - - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - Neither the name of the Mumble Developers nor the names of its - contributors may be used to endorse or promote products derived from this - software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef MUMBLE_MUMBLE_FILEENGINE_H_ -#define MUMBLE_MUMBLE_FILEENGINE_H_ - -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) // QAbstractFileEngineHandler is private in Qt 5. - -class MumbleFileEngineHandler : public QAbstractFileEngineHandler { - private: - Q_DISABLE_COPY(MumbleFileEngineHandler) - public: - MumbleFileEngineHandler(); - QAbstractFileEngine *create(const QString &) const; -}; - -class MumbleImageFileEngine : public QAbstractFileEngine { - private: - Q_DISABLE_COPY(MumbleImageFileEngine) - protected: - QBuffer qbData; - QUrl quUrl; - QStringList qslPath; - public: - MumbleImageFileEngine(const QUrl &); - bool open(QIODevice::OpenMode); - bool close(); - bool seek(qint64 offset); - qint64 pos() const; - qint64 size() const; - qint64 read(char *data, qint64 maxlen); - QString fileName(QAbstractFileEngine::FileName) const; -}; - -#endif - -#endif diff --git a/src/mumble/UserModel.cpp b/src/mumble/UserModel.cpp index a702e9d8d..7fd119b41 100644 --- a/src/mumble/UserModel.cpp +++ b/src/mumble/UserModel.cpp @@ -519,11 +519,15 @@ QVariant UserModel::otherRoles(const QModelIndex &idx, int role) const { qb.open(QIODevice::ReadOnly); QImageReader qir(&qb, p->qbaTextureFormat); QSize sz = qir.size(); - if (sz.width() > 128) { - int targ = sz.width() / ((sz.width()+127)/ 128); - qsImage = QString::fromLatin1("").arg(p->uiSession).arg(QString::fromLatin1(p->qbaTextureFormat).toLower()).arg(targ); - } else if (sz.width() > 0) { - qsImage = QString::fromLatin1("").arg(p->uiSession).arg(QString::fromLatin1(p->qbaTextureFormat).toLower()); + if (sz.width() > 0) { + qsImage = QString::fromLatin1("qbaTexture.toBase64().toPercentEncoding())); + if (sz.width() > 128) { + int targ = sz.width() / ((sz.width()+127)/ 128); + qsImage.append(QString::fromLatin1("\" width=\"%1\" />").arg(targ)); + } else { + qsImage.append(QString::fromLatin1("\" />")); + } } } } diff --git a/src/mumble/mumble.pro b/src/mumble/mumble.pro index d53a3c4a8..a5e631910 100644 --- a/src/mumble/mumble.pro +++ b/src/mumble/mumble.pro @@ -17,8 +17,8 @@ isEqual(QT_MAJOR_VERSION, 5) { } TARGET = mumble -HEADERS *= BanEditor.h ACLEditor.h ConfigWidget.h Log.h AudioConfigDialog.h AudioStats.h AudioInput.h AudioOutput.h AudioOutputSample.h AudioOutputSpeech.h AudioOutputUser.h CELTCodec.h CustomElements.h MainWindow.h ServerHandler.h About.h ConnectDialog.h GlobalShortcut.h TextToSpeech.h Settings.h Database.h VersionCheck.h Global.h UserModel.h Audio.h ConfigDialog.h Plugins.h PTTButtonWidget.h LookConfig.h Overlay.h OverlayText.h SharedMemory.h AudioWizard.h ViewCert.h TextMessage.h NetworkConfig.h LCD.h Usage.h Cert.h ClientUser.h UserEdit.h Tokens.h UserView.h RichTextEditor.h UserInformation.h FileEngine.h SocketRPC.h VoiceRecorder.h VoiceRecorderDialog.h WebFetch.h ../SignalCurry.h -SOURCES *= BanEditor.cpp ACLEditor.cpp ConfigWidget.cpp Log.cpp AudioConfigDialog.cpp AudioStats.cpp AudioInput.cpp AudioOutput.cpp AudioOutputSample.cpp AudioOutputSpeech.cpp AudioOutputUser.cpp main.cpp CELTCodec.cpp CustomElements.cpp MainWindow.cpp ServerHandler.cpp About.cpp ConnectDialog.cpp Settings.cpp Database.cpp VersionCheck.cpp Global.cpp UserModel.cpp Audio.cpp ConfigDialog.cpp Plugins.cpp PTTButtonWidget.cpp LookConfig.cpp OverlayClient.cpp OverlayConfig.cpp OverlayEditor.cpp OverlayEditorScene.cpp OverlayUser.cpp OverlayUserGroup.cpp Overlay.cpp OverlayText.cpp SharedMemory.cpp AudioWizard.cpp ViewCert.cpp Messages.cpp TextMessage.cpp GlobalShortcut.cpp NetworkConfig.cpp LCD.cpp Usage.cpp Cert.cpp ClientUser.cpp UserEdit.cpp Tokens.cpp UserView.cpp RichTextEditor.cpp UserInformation.cpp FileEngine.cpp SocketRPC.cpp VoiceRecorder.cpp VoiceRecorderDialog.cpp WebFetch.cpp +HEADERS *= BanEditor.h ACLEditor.h ConfigWidget.h Log.h AudioConfigDialog.h AudioStats.h AudioInput.h AudioOutput.h AudioOutputSample.h AudioOutputSpeech.h AudioOutputUser.h CELTCodec.h CustomElements.h MainWindow.h ServerHandler.h About.h ConnectDialog.h GlobalShortcut.h TextToSpeech.h Settings.h Database.h VersionCheck.h Global.h UserModel.h Audio.h ConfigDialog.h Plugins.h PTTButtonWidget.h LookConfig.h Overlay.h OverlayText.h SharedMemory.h AudioWizard.h ViewCert.h TextMessage.h NetworkConfig.h LCD.h Usage.h Cert.h ClientUser.h UserEdit.h Tokens.h UserView.h RichTextEditor.h UserInformation.h SocketRPC.h VoiceRecorder.h VoiceRecorderDialog.h WebFetch.h ../SignalCurry.h +SOURCES *= BanEditor.cpp ACLEditor.cpp ConfigWidget.cpp Log.cpp AudioConfigDialog.cpp AudioStats.cpp AudioInput.cpp AudioOutput.cpp AudioOutputSample.cpp AudioOutputSpeech.cpp AudioOutputUser.cpp main.cpp CELTCodec.cpp CustomElements.cpp MainWindow.cpp ServerHandler.cpp About.cpp ConnectDialog.cpp Settings.cpp Database.cpp VersionCheck.cpp Global.cpp UserModel.cpp Audio.cpp ConfigDialog.cpp Plugins.cpp PTTButtonWidget.cpp LookConfig.cpp OverlayClient.cpp OverlayConfig.cpp OverlayEditor.cpp OverlayEditorScene.cpp OverlayUser.cpp OverlayUserGroup.cpp Overlay.cpp OverlayText.cpp SharedMemory.cpp AudioWizard.cpp ViewCert.cpp Messages.cpp TextMessage.cpp GlobalShortcut.cpp NetworkConfig.cpp LCD.cpp Usage.cpp Cert.cpp ClientUser.cpp UserEdit.cpp Tokens.cpp UserView.cpp RichTextEditor.cpp UserInformation.cpp SocketRPC.cpp VoiceRecorder.cpp VoiceRecorderDialog.cpp WebFetch.cpp SOURCES *= smallft.cpp DIST *= ../../icons/mumble.ico licenses.h smallft.h ../../icons/mumble.xpm murmur_pch.h mumble.plist RESOURCES *= mumble.qrc mumble_flags.qrc