summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorLorn Potter <lorn.potter@nokia.com>2010-03-24 23:06:43 (GMT)
committerLorn Potter <lorn.potter@nokia.com>2010-03-24 23:06:43 (GMT)
commitd20510dd91e01b15e2346c0cb12e352080b6a093 (patch)
tree83554f5c96f69df6fe6d9d5c2a9f529a3b1316d8 /src/plugins
parentf727f993c3c4e3f548b06d57b3ee0da4f3914bae (diff)
parent8218a16815d883823d3411be9896332b997f3e91 (diff)
downloadQt-d20510dd91e01b15e2346c0cb12e352080b6a093.zip
Qt-d20510dd91e01b15e2346c0cb12e352080b6a093.tar.gz
Qt-d20510dd91e01b15e2346c0cb12e352080b6a093.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7
Conflicts: src/plugins/bearer/corewlan/qcorewlanengine.mm
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/bearer/corewlan/qcorewlanengine.h3
-rw-r--r--src/plugins/bearer/corewlan/qcorewlanengine.mm14
-rw-r--r--src/plugins/bearer/generic/qgenericengine.cpp2
-rw-r--r--src/plugins/bearer/icd/qicdengine.cpp2
-rw-r--r--src/plugins/bearer/icd/qnetworksession_impl.cpp2
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerservice.h16
-rw-r--r--src/plugins/bearer/symbian/qnetworksession_impl.cpp67
-rw-r--r--src/plugins/bearer/symbian/qnetworksession_impl.h7
-rw-r--r--src/plugins/bearer/symbian/symbianengine.cpp79
-rw-r--r--src/plugins/bearer/symbian/symbianengine.h6
-rw-r--r--src/plugins/imageformats/jpeg/qjpeghandler.cpp396
-rw-r--r--src/plugins/imageformats/jpeg/qjpeghandler.h7
-rw-r--r--src/plugins/mediaservices/qt7/qt7movieviewoutput.h1
-rw-r--r--src/plugins/mediaservices/qt7/qt7movieviewoutput.mm32
14 files changed, 391 insertions, 243 deletions
diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.h b/src/plugins/bearer/corewlan/qcorewlanengine.h
index 2fe8974..02766c5 100644
--- a/src/plugins/bearer/corewlan/qcorewlanengine.h
+++ b/src/plugins/bearer/corewlan/qcorewlanengine.h
@@ -95,11 +95,10 @@ private:
SCDynamicStoreRef storeSession;
CFRunLoopSourceRef runloopSource;
-
bool hasWifi;
protected:
- QMap<QString, QMap<QString,QString> > userProfiles;
+ QMap<QString, QMap<QString,QString> > userProfiles;
void startNetworkChangeLoop();
void getUserConfigurations();
diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm
index af57159..9c2cb0c 100644
--- a/src/plugins/bearer/corewlan/qcorewlanengine.mm
+++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm
@@ -50,11 +50,13 @@
#include <QtCore/qstringlist.h>
#include <QtCore/qdebug.h>
+
#include <QDir>
#include <CoreWLAN/CoreWLAN.h>
#include <CoreWLAN/CWInterface.h>
#include <CoreWLAN/CWNetwork.h>
#include <CoreWLAN/CWNetwork.h>
+#include <CoreWLAN/CW8021XProfile.h>
#include <Foundation/NSEnumerator.h>
#include <Foundation/NSKeyValueObserving.h>
@@ -194,14 +196,14 @@ void QCoreWlanEngine::connectToId(const QString &id)
NSString *wantedSsid = 0;
bool okToProceed = true;
+
if(getNetworkNameFromSsid(id) != id) {
NSArray *array = [CW8021XProfile allUser8021XProfiles];
for (NSUInteger i=0; i<[array count]; ++i) {
const QString idCheck = QString::number(qHash(QLatin1String("corewlan:") + qt_mac_NSStringToQString([[array objectAtIndex:i] userDefinedName])));
const QString idCheck2 = QString::number(qHash(QLatin1String("corewlan:") + qt_mac_NSStringToQString([[array objectAtIndex:i] ssid])));
- if(id == idCheck
- || id == idCheck2) {
+ if (id == idCheck || id == idCheck2) {
QString thisName = getSsidFromNetworkName(id);
if(thisName.isEmpty()) {
wantedSsid = qt_mac_QStringToNSString(id);
@@ -263,6 +265,8 @@ void QCoreWlanEngine::connectToId(const QString &id)
emit connectionError(id, InterfaceLookupError);
locker.relock();
}
+
+ locker.unlock();
emit connectionError(id, OperationNotSupported);
}
@@ -416,7 +420,6 @@ QStringList QCoreWlanEngine::scanForSsids(const QString &interfaceName)
if (!err) {
for(uint row=0; row < [apArray count]; row++ ) {
-
apNetwork = [apArray objectAtIndex:row];
const QString networkSsid = qt_mac_NSStringToQString([apNetwork ssid]);
@@ -456,7 +459,6 @@ QStringList QCoreWlanEngine::scanForSsids(const QString &interfaceName)
QString networkSsid = getSsidFromNetworkName(networkName);
const QString ssidId = QString::number(qHash(QLatin1String("corewlan:") + networkSsid));
QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined;
-
QString interfaceName;
QMapIterator<QString, QString> ij(i.value());
while (ij.hasNext()) {
@@ -693,7 +695,6 @@ QString QCoreWlanEngine::getSsidFromNetworkName(const QString &name)
QMapIterator<QString, QMap<QString,QString> > i(userProfiles);
while (i.hasNext()) {
i.next();
-
QMap<QString,QString> map = i.value();
QMapIterator<QString, QString> ij(i.value());
while (ij.hasNext()) {
@@ -702,7 +703,7 @@ QString QCoreWlanEngine::getSsidFromNetworkName(const QString &name)
if(name == i.key() || name == idCheck) {
return ij.key();
}
- }
+ }
}
return QString();
}
@@ -737,7 +738,6 @@ void QCoreWlanEngine::getUserConfigurations()
CWInterface *wifiInterface = [CWInterface interfaceWithName: [wifiInterfaces objectAtIndex:row]];
NSString *nsInterfaceName = [wifiInterface name];
-
// add user configured system networks
SCDynamicStoreRef dynRef = SCDynamicStoreCreate(kCFAllocatorSystemDefault, (CFStringRef)@"Qt corewlan", nil, nil);
NSDictionary * airportPlist = (NSDictionary *)SCDynamicStoreCopyValue(dynRef, (CFStringRef)[NSString stringWithFormat:@"Setup:/Network/Interface/%@/AirPort", nsInterfaceName]);
diff --git a/src/plugins/bearer/generic/qgenericengine.cpp b/src/plugins/bearer/generic/qgenericengine.cpp
index dfc74f2..c1de4e0 100644
--- a/src/plugins/bearer/generic/qgenericengine.cpp
+++ b/src/plugins/bearer/generic/qgenericengine.cpp
@@ -203,7 +203,7 @@ void QGenericEngine::doRequestUpdate()
if (interface.flags() & QNetworkInterface::IsLoopBack)
continue;
- // ignore WLAN interface handled in seperate engine
+ // ignore WLAN interface handled in separate engine
if (qGetInterfaceType(interface.name()) == QLatin1String("WLAN"))
continue;
diff --git a/src/plugins/bearer/icd/qicdengine.cpp b/src/plugins/bearer/icd/qicdengine.cpp
index f70a209..7a4cb9d 100644
--- a/src/plugins/bearer/icd/qicdengine.cpp
+++ b/src/plugins/bearer/icd/qicdengine.cpp
@@ -335,7 +335,7 @@ void QIcdEngine::doRequestUpdate()
locker.relock();
}
- if (!ap.scan.network_type.startsWith("WLAN"))
+ if (!ap.scan.network_type.startsWith(QLatin1String("WLAN")))
continue; // not a wlan AP
}
} else {
diff --git a/src/plugins/bearer/icd/qnetworksession_impl.cpp b/src/plugins/bearer/icd/qnetworksession_impl.cpp
index a2ae65c..06e0529 100644
--- a/src/plugins/bearer/icd/qnetworksession_impl.cpp
+++ b/src/plugins/bearer/icd/qnetworksession_impl.cpp
@@ -391,7 +391,7 @@ quint64 QNetworkSessionPrivateImpl::getStatistics(bool sent) const
return 0;
}
- foreach (Maemo::IcdStatisticsResult res, stats_results) {
+ foreach (const Maemo::IcdStatisticsResult &res, stats_results) {
if (res.params.network_attrs & ICD_NW_ATTR_IAPNAME) {
/* network_id is the IAP UUID */
if (QString(res.params.network_id.data()) == activeConfig.identifier()) {
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
index 048f628..ecca537 100644
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
@@ -215,7 +215,7 @@ public:
Q_DECLARE_FLAGS(ApSecurityFlags, ApSecurityFlag);
- QNetworkManagerInterfaceAccessPoint(const QString &dbusPathName, QObject *parent = 0);
+ explicit QNetworkManagerInterfaceAccessPoint(const QString &dbusPathName, QObject *parent = 0);
~QNetworkManagerInterfaceAccessPoint();
QDBusInterface *connectionInterface() const;
@@ -248,7 +248,7 @@ class QNetworkManagerInterfaceDevice : public QObject
public:
- QNetworkManagerInterfaceDevice(const QString &deviceObjectPath, QObject *parent = 0);
+ explicit QNetworkManagerInterfaceDevice(const QString &deviceObjectPath, QObject *parent = 0);
~QNetworkManagerInterfaceDevice();
QString udi() const;
@@ -277,7 +277,8 @@ class QNetworkManagerInterfaceDeviceWired : public QObject
public:
- QNetworkManagerInterfaceDeviceWired(const QString &ifaceDevicePath, QObject *parent = 0);
+ explicit QNetworkManagerInterfaceDeviceWired(const QString &ifaceDevicePath,
+ QObject *parent = 0);
~QNetworkManagerInterfaceDeviceWired();
QDBusInterface *connectionInterface() const;
@@ -311,7 +312,8 @@ public:
Rsn = 0x20
};
- QNetworkManagerInterfaceDeviceWireless(const QString &ifaceDevicePath, QObject *parent = 0);
+ explicit QNetworkManagerInterfaceDeviceWireless(const QString &ifaceDevicePath,
+ QObject *parent = 0);
~QNetworkManagerInterfaceDeviceWireless();
QDBusObjectPath path() const;
@@ -342,7 +344,7 @@ class QNetworkManagerSettings : public QObject
public:
- QNetworkManagerSettings(const QString &settingsService, QObject *parent = 0);
+ explicit QNetworkManagerSettings(const QString &settingsService, QObject *parent = 0);
~QNetworkManagerSettings();
QDBusInterface *connectionInterface() const;
@@ -402,7 +404,7 @@ public:
Activated = 2
};
- QNetworkManagerConnectionActive(const QString &dbusPathName, QObject *parent = 0);
+ explicit QNetworkManagerConnectionActive(const QString &dbusPathName, QObject *parent = 0);
~ QNetworkManagerConnectionActive();
QDBusInterface *connectionInterface() const;
@@ -430,7 +432,7 @@ class QNetworkManagerIp4Config : public QObject
Q_OBJECT
public:
- QNetworkManagerIp4Config(const QString &dbusPathName, QObject *parent = 0);
+ explicit QNetworkManagerIp4Config(const QString &dbusPathName, QObject *parent = 0);
~QNetworkManagerIp4Config();
QStringList domains() const;
diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp
index 0737942..8910efe 100644
--- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp
+++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp
@@ -241,15 +241,24 @@ void QNetworkSessionPrivateImpl::open()
// => RConnection::ProgressNotification will be used for IAP/SNAP monitoring
iConnectionMonitor.CancelNotifications();
- // Configuration must be at least in Discovered - state for connecting purposes.
- if ((publicConfig.state() & QNetworkConfiguration::Discovered) !=
- QNetworkConfiguration::Discovered) {
+ // Configuration may have been invalidated after session creation by platform
+ // (e.g. configuration has been deleted).
+ if (!publicConfig.isValid()) {
newState(QNetworkSession::Invalid);
iError = QNetworkSession::InvalidConfigurationError;
emit QNetworkSessionPrivate::error(iError);
syncStateWithInterface();
return;
}
+ // If opening a (un)defined configuration, session emits error and enters
+ // NotAvailable -state.
+ if (publicConfig.state() == QNetworkConfiguration::Undefined ||
+ publicConfig.state() == QNetworkConfiguration::Defined) {
+ newState(QNetworkSession::NotAvailable);
+ iError = QNetworkSession::InvalidConfigurationError;
+ emit QNetworkSessionPrivate::error(iError);
+ return;
+ }
TInt error = iSocketServ.Connect();
if (error != KErrNone) {
@@ -450,15 +459,49 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals)
void QNetworkSessionPrivateImpl::stop()
{
- if (!isOpen) {
- return;
+ if (!isOpen &&
+ publicConfig.isValid() &&
+ publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) {
+ // If the publicConfig is type of IAP, enumerate through connections at
+ // connection monitor. If publicConfig is active in that list, stop it.
+ // Otherwise there is nothing to stop. Note: because this QNetworkSession is not open,
+ // activeConfig is not usable.
+ TUint count;
+ TRequestStatus status;
+ iConnectionMonitor.GetConnectionCount(count, status);
+ User::WaitForRequest(status);
+ if (status.Int() != KErrNone) {
+ return;
+ }
+ TUint numSubConnections; // Not used but needed by GetConnectionInfo i/f
+ TUint connectionId;
+ for (TInt i = 1; i <= count; ++i) {
+ // Get (connection monitor's assigned) connection ID
+ TInt ret = iConnectionMonitor.GetConnectionInfo(i, connectionId, numSubConnections);
+ if (ret == KErrNone) {
+ SymbianNetworkConfigurationPrivate *symbianConfig =
+ toSymbianConfig(privateConfiguration(publicConfig));
+
+ QMutexLocker configLocker(&symbianConfig->mutex);
+
+ // See if connection Id matches with our Id. If so, stop() it.
+ if (symbianConfig->connectionId == connectionId) {
+ ret = iConnectionMonitor.SetBoolAttribute(connectionId,
+ 0, // subConnectionId don't care
+ KConnectionStop,
+ ETrue);
+ }
+ }
+ }
+ } else if (isOpen) {
+ // Since we are open, use RConnection to stop the interface
+ isOpen = false;
+ newState(QNetworkSession::Closing);
+ iConnection.Stop(RConnection::EStopAuthoritative);
+ isOpen = true;
+ close(false);
+ emit closed();
}
- isOpen = false;
- newState(QNetworkSession::Closing);
- iConnection.Stop(RConnection::EStopAuthoritative);
- isOpen = true;
- close(false);
- emit closed();
}
void QNetworkSessionPrivateImpl::migrate()
@@ -794,7 +837,7 @@ void QNetworkSessionPrivateImpl::RunL()
TInt statusCode = iStatus.Int();
switch (statusCode) {
- case KErrNone: // Connection created succesfully
+ case KErrNone: // Connection created successfully
{
TInt error = KErrNone;
QNetworkConfiguration newActiveConfig = activeConfiguration();
diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.h b/src/plugins/bearer/symbian/qnetworksession_impl.h
index 98d4222..35e2c58 100644
--- a/src/plugins/bearer/symbian/qnetworksession_impl.h
+++ b/src/plugins/bearer/symbian/qnetworksession_impl.h
@@ -72,12 +72,11 @@ QT_BEGIN_NAMESPACE
class ConnectionProgressNotifier;
class SymbianEngine;
+class QNetworkSessionPrivateImpl : public QNetworkSessionPrivate, public CActive,
#ifdef SNAP_FUNCTIONALITY_AVAILABLE
-class QNetworkSessionPrivateImpl : public QNetworkSessionPrivate, public CActive, public MMobilityProtocolResp,
- public MConnectionMonitorObserver
-#else
-class QNetworkSessionPrivateImpl : public QNetworkSessionPrivate, public CActive, public MConnectionMonitorObserver
+ public MMobilityProtocolResp,
#endif
+ public MConnectionMonitorObserver
{
Q_OBJECT
public:
diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp
index 4d65b80..440f463 100644
--- a/src/plugins/bearer/symbian/symbianengine.cpp
+++ b/src/plugins/bearer/symbian/symbianengine.cpp
@@ -45,6 +45,16 @@
#include <commdb.h>
#include <cdbcols.h>
#include <d32dbms.h>
+#include <QEventLoop>
+#include <QTimer>
+#include <QTime> // For randgen seeding
+#include <QtCore> // For randgen seeding
+
+// #define QT_BEARERMGMT_CONFIGMGR_DEBUG
+
+#ifdef QT_BEARERMGMT_CONFIGMGR_DEBUG
+#include <QDebug>
+#endif
#ifdef SNAP_FUNCTIONALITY_AVAILABLE
#include <cmdestination.h>
@@ -100,10 +110,15 @@ QString SymbianNetworkConfigurationPrivate::bearerName() const
}
SymbianEngine::SymbianEngine(QObject *parent)
-: QBearerEngine(parent), CActive(CActive::EPriorityIdle), iFirstUpdate(true), iInitOk(true)
+: QBearerEngine(parent), CActive(CActive::EPriorityIdle), iFirstUpdate(true), iInitOk(true),
+ iIgnoringUpdates(false), iTimeToWait(0), iIgnoreEventLoop(0)
{
CActiveScheduler::Add(this);
+ // Seed the randomgenerator
+ qsrand(QTime(0,0,0).secsTo(QTime::currentTime()) + QCoreApplication::applicationPid());
+ iIgnoreEventLoop = new QEventLoop(this);
+
TRAPD(error, ipCommsDB = CCommsDatabase::NewL(EDatabaseTypeIAP));
if (error != KErrNone) {
iInitOk = false;
@@ -138,9 +153,7 @@ SymbianEngine::SymbianEngine(QObject *parent)
updateConfigurations();
updateStatesToSnaps();
-
updateAvailableAccessPoints(); // On first time updates synchronously (without WLAN scans)
-
// Start monitoring IAP and/or SNAP changes in Symbian CommsDB
startCommsDatabaseNotifications();
iFirstUpdate = false;
@@ -231,7 +244,7 @@ void SymbianEngine::updateConfigurationsL()
QList<QString> knownConfigs = accessPointConfigurations.keys();
QList<QString> knownSnapConfigs = snapConfigurations.keys();
-
+
#ifdef SNAP_FUNCTIONALITY_AVAILABLE
// S60 version is >= Series60 3rd Edition Feature Pack 2
TInt error = KErrNone;
@@ -738,8 +751,7 @@ void SymbianEngine::updateStatesToSnaps()
QMutexLocker locker(&mutex);
// Go through SNAPs and set correct state to SNAPs
- QList<QString> snapConfigIdents = snapConfigurations.keys();
- foreach (QString iface, snapConfigIdents) {
+ foreach (const QString &iface, snapConfigurations.keys()) {
bool discovered = false;
bool active = false;
QNetworkConfigurationPrivatePointer ptr = snapConfigurations.value(iface);
@@ -874,6 +886,13 @@ void SymbianEngine::RunL()
{
QMutexLocker locker(&mutex);
+ if (iIgnoringUpdates) {
+#ifdef QT_BEARERMGMT_CONFIGMGR_DEBUG
+ qDebug("CommsDB event handling postponed (postpone-timer running because IAPs/SNAPs were updated very recently).");
+#endif
+ return;
+ }
+
if (iStatus != KErrCancel) {
RDbNotifier::TEvent event = STATIC_CAST(RDbNotifier::TEvent, iStatus.Int());
switch (event) {
@@ -881,16 +900,32 @@ void SymbianEngine::RunL()
case RDbNotifier::ECommit: /** A transaction has been committed. */
case RDbNotifier::ERollback: /** A transaction has been rolled back */
case RDbNotifier::ERecover: /** The database has been recovered */
- // Note that if further database events occur while a client is handling
- // a request completion, the notifier records the most significant database
- // event and this is signalled as soon as the client issues the next
- // RequestNotification() request.
- // => Stop recording notifications
- stopCommsDatabaseNotifications();
- TRAPD(error, updateConfigurationsL());
- if (error == KErrNone) {
- updateStatesToSnaps();
+#ifdef QT_BEARERMGMT_CONFIGMGR_DEBUG
+ qDebug("CommsDB event (of type RDbNotifier::TEvent) received: %d", iStatus.Int());
+#endif
+ iIgnoringUpdates = true;
+ // Other events than ECommit get lower priority. In practice with those events,
+ // we delay_before_updating methods, whereas
+ // with ECommit we _update_before_delaying the reaction to next event.
+ // Few important notes: 1) listening to only ECommit does not seem to be adequate,
+ // but updates will be missed. Hence other events are reacted upon too.
+ // 2) RDbNotifier records the most significant event, and that will be returned once
+ // we issue new RequestNotification, and hence updates will not be missed even
+ // when we are 'not reacting to them' for few seconds.
+ if (event == RDbNotifier::ECommit) {
+ TRAPD(error, updateConfigurationsL());
+ if (error == KErrNone) {
+ updateStatesToSnaps();
+ }
+ waitRandomTime();
+ } else {
+ waitRandomTime();
+ TRAPD(error, updateConfigurationsL());
+ if (error == KErrNone) {
+ updateStatesToSnaps();
+ }
}
+ iIgnoringUpdates = false; // Wait time done, allow updating again
iWaitingCommsDatabaseNotifications = true;
break;
default:
@@ -1015,6 +1050,20 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent)
}
}
+// Waits for 1..4 seconds.
+void SymbianEngine::waitRandomTime()
+{
+ iTimeToWait = (qAbs(qrand()) % 5) * 1000;
+ if (iTimeToWait < 1000) {
+ iTimeToWait = 1000;
+ }
+#ifdef QT_BEARERMGMT_CONFIGMGR_DEBUG
+ qDebug("QNetworkConfigurationManager waiting random time: %d ms", iTimeToWait);
+#endif
+ QTimer::singleShot(iTimeToWait, iIgnoreEventLoop, SLOT(quit()));
+ iIgnoreEventLoop->exec();
+}
+
QNetworkConfigurationPrivatePointer SymbianEngine::dataByConnectionId(TUint aConnectionId)
{
QMutexLocker locker(&mutex);
diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h
index e6af908..2e7ae60 100644
--- a/src/plugins/bearer/symbian/symbianengine.h
+++ b/src/plugins/bearer/symbian/symbianengine.h
@@ -53,6 +53,7 @@
#endif
class CCommsDatabase;
+class QEventLoop;
QT_BEGIN_NAMESPACE
class QTimer;
@@ -148,6 +149,7 @@ private:
void accessPointScanningReady(TBool scanSuccessful, TConnMonIapInfo iapInfo);
void startCommsDatabaseNotifications();
void stopCommsDatabaseNotifications();
+ void waitRandomTime();
QNetworkConfigurationPrivatePointer defaultConfigurationL();
TBool GetS60PlatformVersion(TUint& aMajor, TUint& aMinor) const;
@@ -170,8 +172,10 @@ private: // Data
TBool iOnline;
TBool iInitOk;
TBool iUpdateGoingOn;
+ TBool iIgnoringUpdates;
+ TUint iTimeToWait;
+ QEventLoop* iIgnoreEventLoop;
-
AccessPointsAvailabilityScanner* ipAccessPointsAvailabilityScanner;
friend class QNetworkSessionPrivate;
diff --git a/src/plugins/imageformats/jpeg/qjpeghandler.cpp b/src/plugins/imageformats/jpeg/qjpeghandler.cpp
index abe3ffe..93b7cc6 100644
--- a/src/plugins/imageformats/jpeg/qjpeghandler.cpp
+++ b/src/plugins/imageformats/jpeg/qjpeghandler.cpp
@@ -183,82 +183,34 @@ inline my_jpeg_source_mgr::my_jpeg_source_mgr(QIODevice *device)
}
-static bool read_jpeg_size(QIODevice *device, int &w, int &h)
+inline static bool read_jpeg_size(int &w, int &h, j_decompress_ptr cinfo)
{
- bool rt = false;
- struct jpeg_decompress_struct cinfo;
+ (void) jpeg_calc_output_dimensions(cinfo);
- struct my_jpeg_source_mgr *iod_src = new my_jpeg_source_mgr(device);
- struct my_error_mgr jerr;
-
- jpeg_create_decompress(&cinfo);
-
- cinfo.src = iod_src;
-
- cinfo.err = jpeg_std_error(&jerr);
- jerr.error_exit = my_error_exit;
-
- if (!setjmp(jerr.setjmp_buffer)) {
-#if defined(Q_OS_UNIXWARE)
- (void) jpeg_read_header(&cinfo, B_TRUE);
-#else
- (void) jpeg_read_header(&cinfo, true);
-#endif
- (void) jpeg_calc_output_dimensions(&cinfo);
-
- w = cinfo.output_width;
- h = cinfo.output_height;
- rt = true;
- }
- jpeg_destroy_decompress(&cinfo);
- delete iod_src;
- return rt;
+ w = cinfo->output_width;
+ h = cinfo->output_height;
+ return true;
}
#define HIGH_QUALITY_THRESHOLD 50
-static bool read_jpeg_format(QIODevice *device, QImage::Format &format)
+inline static bool read_jpeg_format(QImage::Format &format, j_decompress_ptr cinfo)
{
- bool result = false;
- struct jpeg_decompress_struct cinfo;
-
- struct my_jpeg_source_mgr *iod_src = new my_jpeg_source_mgr(device);
- struct my_error_mgr jerr;
-
- jpeg_create_decompress(&cinfo);
-
- cinfo.src = iod_src;
-
- cinfo.err = jpeg_std_error(&jerr);
- jerr.error_exit = my_error_exit;
- if (!setjmp(jerr.setjmp_buffer)) {
-#if defined(Q_OS_UNIXWARE)
- (void) jpeg_read_header(&cinfo, B_TRUE);
-#else
- (void) jpeg_read_header(&cinfo, true);
-#endif
- // This does not allocate memory for the whole image
- // or such, so we are safe.
- (void) jpeg_start_decompress(&cinfo);
- result = true;
- switch (cinfo.output_components) {
- case 1:
- format = QImage::Format_Indexed8;
- break;
- case 3:
- case 4:
- format = QImage::Format_RGB32;
- break;
- default:
- result = false;
- break;
- }
- cinfo.output_scanline = cinfo.output_height;
- (void) jpeg_finish_decompress(&cinfo);
+ bool result = true;
+ switch (cinfo->output_components) {
+ case 1:
+ format = QImage::Format_Indexed8;
+ break;
+ case 3:
+ case 4:
+ format = QImage::Format_RGB32;
+ break;
+ default:
+ result = false;
+ break;
}
- jpeg_destroy_decompress(&cinfo);
- delete iod_src;
+ cinfo->output_scanline = cinfo->output_height;
return result;
}
@@ -291,29 +243,11 @@ static bool ensureValidImage(QImage *dest, struct jpeg_decompress_struct *info,
return !dest->isNull();
}
-static bool read_jpeg_image(QIODevice *device, QImage *outImage,
+static bool read_jpeg_image(QImage *outImage,
QSize scaledSize, QRect scaledClipRect,
- QRect clipRect, int inQuality )
+ QRect clipRect, int inQuality, j_decompress_ptr info, struct my_error_mgr* err )
{
- struct jpeg_decompress_struct cinfo;
-
- struct my_jpeg_source_mgr *iod_src = new my_jpeg_source_mgr(device);
- struct my_error_mgr jerr;
-
- jpeg_create_decompress(&cinfo);
-
- cinfo.src = iod_src;
-
- cinfo.err = jpeg_std_error(&jerr);
- jerr.error_exit = my_error_exit;
-
- if (!setjmp(jerr.setjmp_buffer)) {
-#if defined(Q_OS_UNIXWARE)
- (void) jpeg_read_header(&cinfo, B_TRUE);
-#else
- (void) jpeg_read_header(&cinfo, true);
-#endif
-
+ if (!setjmp(err->setjmp_buffer)) {
// -1 means default quality.
int quality = inQuality;
if (quality < 0)
@@ -335,16 +269,16 @@ static bool read_jpeg_image(QIODevice *device, QImage *outImage,
} else if (clipRect.isEmpty()) {
// No clipping, but scaling: if we can map back to an
// integer pixel boundary, then clip before scaling.
- if ((cinfo.image_width % scaledSize.width()) == 0 &&
- (cinfo.image_height % scaledSize.height()) == 0) {
- int x = scaledClipRect.x() * cinfo.image_width /
+ if ((info->image_width % scaledSize.width()) == 0 &&
+ (info->image_height % scaledSize.height()) == 0) {
+ int x = scaledClipRect.x() * info->image_width /
scaledSize.width();
- int y = scaledClipRect.y() * cinfo.image_height /
+ int y = scaledClipRect.y() * info->image_height /
scaledSize.height();
int width = (scaledClipRect.right() + 1) *
- cinfo.image_width / scaledSize.width() - x;
+ info->image_width / scaledSize.width() - x;
int height = (scaledClipRect.bottom() + 1) *
- cinfo.image_height / scaledSize.height() - y;
+ info->image_height / scaledSize.height() - y;
clipRect = QRect(x, y, width, height);
scaledSize = scaledClipRect.size();
scaledClipRect = QRect();
@@ -358,69 +292,69 @@ static bool read_jpeg_image(QIODevice *device, QImage *outImage,
// Determine the scale factor to pass to libjpeg for quick downscaling.
if (!scaledSize.isEmpty()) {
if (clipRect.isEmpty()) {
- cinfo.scale_denom =
- qMin(cinfo.image_width / scaledSize.width(),
- cinfo.image_height / scaledSize.height());
+ info->scale_denom =
+ qMin(info->image_width / scaledSize.width(),
+ info->image_height / scaledSize.height());
} else {
- cinfo.scale_denom =
+ info->scale_denom =
qMin(clipRect.width() / scaledSize.width(),
clipRect.height() / scaledSize.height());
}
- if (cinfo.scale_denom < 2) {
- cinfo.scale_denom = 1;
- } else if (cinfo.scale_denom < 4) {
- cinfo.scale_denom = 2;
- } else if (cinfo.scale_denom < 8) {
- cinfo.scale_denom = 4;
+ if (info->scale_denom < 2) {
+ info->scale_denom = 1;
+ } else if (info->scale_denom < 4) {
+ info->scale_denom = 2;
+ } else if (info->scale_denom < 8) {
+ info->scale_denom = 4;
} else {
- cinfo.scale_denom = 8;
+ info->scale_denom = 8;
}
- cinfo.scale_num = 1;
+ info->scale_num = 1;
if (!clipRect.isEmpty()) {
// Correct the scale factor so that we clip accurately.
// It is recommended that the clip rectangle be aligned
// on an 8-pixel boundary for best performance.
- while (cinfo.scale_denom > 1 &&
- ((clipRect.x() % cinfo.scale_denom) != 0 ||
- (clipRect.y() % cinfo.scale_denom) != 0 ||
- (clipRect.width() % cinfo.scale_denom) != 0 ||
- (clipRect.height() % cinfo.scale_denom) != 0)) {
- cinfo.scale_denom /= 2;
+ while (info->scale_denom > 1 &&
+ ((clipRect.x() % info->scale_denom) != 0 ||
+ (clipRect.y() % info->scale_denom) != 0 ||
+ (clipRect.width() % info->scale_denom) != 0 ||
+ (clipRect.height() % info->scale_denom) != 0)) {
+ info->scale_denom /= 2;
}
}
}
// If high quality not required, use fast decompression
if( quality < HIGH_QUALITY_THRESHOLD ) {
- cinfo.dct_method = JDCT_IFAST;
- cinfo.do_fancy_upsampling = FALSE;
+ info->dct_method = JDCT_IFAST;
+ info->do_fancy_upsampling = FALSE;
}
- (void) jpeg_calc_output_dimensions(&cinfo);
+ (void) jpeg_calc_output_dimensions(info);
// Determine the clip region to extract.
- QRect imageRect(0, 0, cinfo.output_width, cinfo.output_height);
+ QRect imageRect(0, 0, info->output_width, info->output_height);
QRect clip;
if (clipRect.isEmpty()) {
clip = imageRect;
- } else if (cinfo.scale_denom == cinfo.scale_num) {
+ } else if (info->scale_denom == info->scale_num) {
clip = clipRect.intersected(imageRect);
} else {
// The scale factor was corrected above to ensure that
// we don't miss pixels when we scale the clip rectangle.
- clip = QRect(clipRect.x() / int(cinfo.scale_denom),
- clipRect.y() / int(cinfo.scale_denom),
- clipRect.width() / int(cinfo.scale_denom),
- clipRect.height() / int(cinfo.scale_denom));
+ clip = QRect(clipRect.x() / int(info->scale_denom),
+ clipRect.y() / int(info->scale_denom),
+ clipRect.width() / int(info->scale_denom),
+ clipRect.height() / int(info->scale_denom));
clip = clip.intersected(imageRect);
}
// Allocate memory for the clipped QImage.
- if (!ensureValidImage(outImage, &cinfo, clip.size()))
- longjmp(jerr.setjmp_buffer, 1);
+ if (!ensureValidImage(outImage, info, clip.size()))
+ longjmp(err->setjmp_buffer, 1);
// Avoid memcpy() overhead if grayscale with no clipping.
- bool quickGray = (cinfo.output_components == 1 &&
+ bool quickGray = (info->output_components == 1 &&
clip == imageRect);
if (!quickGray) {
// Ask the jpeg library to allocate a temporary row.
@@ -429,23 +363,23 @@ static bool read_jpeg_image(QIODevice *device, QImage *outImage,
// jpeg_start_decompress(). We can't use "new" here
// because we are inside the setjmp() block and an error
// in the jpeg input stream would cause a memory leak.
- JSAMPARRAY rows = (cinfo.mem->alloc_sarray)
- ((j_common_ptr)&cinfo, JPOOL_IMAGE,
- cinfo.output_width * cinfo.output_components, 1);
+ JSAMPARRAY rows = (info->mem->alloc_sarray)
+ ((j_common_ptr)info, JPOOL_IMAGE,
+ info->output_width * info->output_components, 1);
- (void) jpeg_start_decompress(&cinfo);
+ (void) jpeg_start_decompress(info);
- while (cinfo.output_scanline < cinfo.output_height) {
- int y = int(cinfo.output_scanline) - clip.y();
+ while (info->output_scanline < info->output_height) {
+ int y = int(info->output_scanline) - clip.y();
if (y >= clip.height())
break; // We've read the entire clip region, so abort.
- (void) jpeg_read_scanlines(&cinfo, rows, 1);
+ (void) jpeg_read_scanlines(info, rows, 1);
if (y < 0)
continue; // Haven't reached the starting line yet.
- if (cinfo.output_components == 3) {
+ if (info->output_components == 3) {
// Expand 24->32 bpp.
uchar *in = rows[0] + clip.x() * 3;
QRgb *out = (QRgb*)outImage->scanLine(y);
@@ -453,7 +387,7 @@ static bool read_jpeg_image(QIODevice *device, QImage *outImage,
*out++ = qRgb(in[0], in[1], in[2]);
in += 3;
}
- } else if (cinfo.out_color_space == JCS_CMYK) {
+ } else if (info->out_color_space == JCS_CMYK) {
// Convert CMYK->RGB.
uchar *in = rows[0] + clip.x() * 4;
QRgb *out = (QRgb*)outImage->scanLine(y);
@@ -463,7 +397,7 @@ static bool read_jpeg_image(QIODevice *device, QImage *outImage,
k * in[2] / 255);
in += 4;
}
- } else if (cinfo.output_components == 1) {
+ } else if (info->output_components == 1) {
// Grayscale.
memcpy(outImage->scanLine(y),
rows[0] + clip.x(), clip.width());
@@ -471,37 +405,36 @@ static bool read_jpeg_image(QIODevice *device, QImage *outImage,
}
} else {
// Load unclipped grayscale data directly into the QImage.
- (void) jpeg_start_decompress(&cinfo);
- while (cinfo.output_scanline < cinfo.output_height) {
- uchar *row = outImage->scanLine(cinfo.output_scanline);
- (void) jpeg_read_scanlines(&cinfo, &row, 1);
+ (void) jpeg_start_decompress(info);
+ while (info->output_scanline < info->output_height) {
+ uchar *row = outImage->scanLine(info->output_scanline);
+ (void) jpeg_read_scanlines(info, &row, 1);
}
}
- if (cinfo.output_scanline == cinfo.output_height)
- (void) jpeg_finish_decompress(&cinfo);
+ if (info->output_scanline == info->output_height)
+ (void) jpeg_finish_decompress(info);
- if (cinfo.density_unit == 1) {
- outImage->setDotsPerMeterX(int(100. * cinfo.X_density / 2.54));
- outImage->setDotsPerMeterY(int(100. * cinfo.Y_density / 2.54));
- } else if (cinfo.density_unit == 2) {
- outImage->setDotsPerMeterX(int(100. * cinfo.X_density));
- outImage->setDotsPerMeterY(int(100. * cinfo.Y_density));
+ if (info->density_unit == 1) {
+ outImage->setDotsPerMeterX(int(100. * info->X_density / 2.54));
+ outImage->setDotsPerMeterY(int(100. * info->Y_density / 2.54));
+ } else if (info->density_unit == 2) {
+ outImage->setDotsPerMeterX(int(100. * info->X_density));
+ outImage->setDotsPerMeterY(int(100. * info->Y_density));
}
if (scaledSize.isValid() && scaledSize != clip.size()) {
*outImage = outImage->scaled(scaledSize, Qt::IgnoreAspectRatio, quality >= HIGH_QUALITY_THRESHOLD ? Qt::SmoothTransformation : Qt::FastTransformation);
}
- }
- jpeg_destroy_decompress(&cinfo);
- delete iod_src;
- if (!scaledClipRect.isEmpty())
- *outImage = outImage->copy(scaledClipRect);
- return !outImage->isNull();
+ if (!scaledClipRect.isEmpty())
+ *outImage = outImage->copy(scaledClipRect);
+ return !outImage->isNull();
+ }
+ else
+ return false;
}
-
struct my_jpeg_destination_mgr : public jpeg_destination_mgr {
// Nothing dynamic - cannot rely on destruction over longjump
QIODevice *device;
@@ -745,18 +678,124 @@ static bool write_jpeg_image(const QImage &sourceImage, QIODevice *device, int s
return success;
}
+class QJpegHandlerPrivate
+{
+public:
+ enum State {
+ Ready,
+ ReadHeader,
+ Error
+ };
+
+ QJpegHandlerPrivate(QJpegHandler *qq)
+ : quality(75), iod_src(0), state(Ready), q(qq)
+ {}
+
+ ~QJpegHandlerPrivate()
+ {
+ if(iod_src)
+ {
+ jpeg_destroy_decompress(&info);
+ delete iod_src;
+ iod_src = 0;
+ }
+ }
+
+ bool readJpegHeader(QIODevice*);
+ bool read(QImage *image);
+
+ int quality;
+ QVariant size;
+ QImage::Format format;
+ QSize scaledSize;
+ QRect scaledClipRect;
+ QRect clipRect;
+ struct jpeg_decompress_struct info;
+ struct my_jpeg_source_mgr * iod_src;
+ struct my_error_mgr err;
+
+ State state;
+
+ QJpegHandler *q;
+};
+
+/*!
+ \internal
+*/
+bool QJpegHandlerPrivate::readJpegHeader(QIODevice *device)
+{
+ if(state == Ready)
+ {
+ state = Error;
+ iod_src = new my_jpeg_source_mgr(device);
+
+ jpeg_create_decompress(&info);
+ info.src = iod_src;
+ info.err = jpeg_std_error(&err);
+ err.error_exit = my_error_exit;
+
+ if (!setjmp(err.setjmp_buffer)) {
+ #if defined(Q_OS_UNIXWARE)
+ (void) jpeg_read_header(&info, B_TRUE);
+ #else
+ (void) jpeg_read_header(&info, true);
+ #endif
+
+ int width = 0;
+ int height = 0;
+ read_jpeg_size(width, height, &info);
+ size = QSize(width, height);
+
+ format = QImage::Format_Invalid;
+ read_jpeg_format(format, &info);
+ state = ReadHeader;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ else if(state == Error)
+ return false;
+ return true;
+}
+
+bool QJpegHandlerPrivate::read(QImage *image)
+{
+ if(state == Ready)
+ readJpegHeader(q->device());
+
+ if(state == ReadHeader)
+ {
+ bool success = read_jpeg_image(image, scaledSize, scaledClipRect, clipRect, quality, &info, &err);
+ state = success ? Ready : Error;
+ return success;
+ }
+
+ return false;
+
+}
+
QJpegHandler::QJpegHandler()
+ : d(new QJpegHandlerPrivate(this))
+{
+}
+
+QJpegHandler::~QJpegHandler()
{
- quality = 75;
+ delete d;
}
bool QJpegHandler::canRead() const
{
- if (canRead(device())) {
+ if(d->state == QJpegHandlerPrivate::Ready) {
+ if (!canRead(device()))
+ return false;
setFormat("jpeg");
return true;
}
- return false;
+ return d->state != QJpegHandlerPrivate::Error;
}
bool QJpegHandler::canRead(QIODevice *device)
@@ -769,7 +808,6 @@ bool QJpegHandler::canRead(QIODevice *device)
char buffer[2];
if (device->peek(buffer, 2) != 2)
return false;
-
return uchar(buffer[0]) == 0xff && uchar(buffer[1]) == 0xd8;
}
@@ -777,12 +815,12 @@ bool QJpegHandler::read(QImage *image)
{
if (!canRead())
return false;
- return read_jpeg_image(device(), image, scaledSize, scaledClipRect, clipRect, quality);
+ return d->read(image);
}
bool QJpegHandler::write(const QImage &image)
{
- return write_jpeg_image(image, device(), quality);
+ return write_jpeg_image(image, device(), d->quality);
}
bool QJpegHandler::supportsOption(ImageOption option) const
@@ -799,32 +837,19 @@ QVariant QJpegHandler::option(ImageOption option) const
{
switch(option) {
case Quality:
- return quality;
+ return d->quality;
case ScaledSize:
- return scaledSize;
+ return d->scaledSize;
case ScaledClipRect:
- return scaledClipRect;
+ return d->scaledClipRect;
case ClipRect:
- return clipRect;
+ return d->clipRect;
case Size:
- if (canRead() && !device()->isSequential()) {
- qint64 pos = device()->pos();
- int width = 0;
- int height = 0;
- read_jpeg_size(device(), width, height);
- device()->seek(pos);
- return QSize(width, height);
- }
- return QVariant();
+ d->readJpegHeader(device());
+ return d->size;
case ImageFormat:
- if (canRead() && !device()->isSequential()) {
- qint64 pos = device()->pos();
- QImage::Format format = QImage::Format_Invalid;
- read_jpeg_format(device(), format);
- device()->seek(pos);
- return format;
- }
- return QImage::Format_Invalid;
+ d->readJpegHeader(device());
+ return d->format;
default:
return QVariant();
}
@@ -834,16 +859,16 @@ void QJpegHandler::setOption(ImageOption option, const QVariant &value)
{
switch(option) {
case Quality:
- quality = value.toInt();
+ d->quality = value.toInt();
break;
case ScaledSize:
- scaledSize = value.toSize();
+ d->scaledSize = value.toSize();
break;
case ScaledClipRect:
- scaledClipRect = value.toRect();
+ d->scaledClipRect = value.toRect();
break;
case ClipRect:
- clipRect = value.toRect();
+ d->clipRect = value.toRect();
break;
default:
break;
@@ -855,4 +880,7 @@ QByteArray QJpegHandler::name() const
return "jpeg";
}
+
+
+
QT_END_NAMESPACE
diff --git a/src/plugins/imageformats/jpeg/qjpeghandler.h b/src/plugins/imageformats/jpeg/qjpeghandler.h
index dfb6b47..c879f21 100644
--- a/src/plugins/imageformats/jpeg/qjpeghandler.h
+++ b/src/plugins/imageformats/jpeg/qjpeghandler.h
@@ -48,10 +48,12 @@
QT_BEGIN_NAMESPACE
+class QJpegHandlerPrivate;
class QJpegHandler : public QImageIOHandler
{
public:
QJpegHandler();
+ ~QJpegHandler();
bool canRead() const;
bool read(QImage *image);
@@ -66,10 +68,7 @@ public:
bool supportsOption(ImageOption option) const;
private:
- int quality;
- QSize scaledSize;
- QRect scaledClipRect;
- QRect clipRect;
+ QJpegHandlerPrivate *d;
};
QT_END_NAMESPACE
diff --git a/src/plugins/mediaservices/qt7/qt7movieviewoutput.h b/src/plugins/mediaservices/qt7/qt7movieviewoutput.h
index 31a0314..49049ad 100644
--- a/src/plugins/mediaservices/qt7/qt7movieviewoutput.h
+++ b/src/plugins/mediaservices/qt7/qt7movieviewoutput.h
@@ -100,6 +100,7 @@ private:
void *m_movie;
void *m_movieView;
+ bool m_layouted;
WId m_winId;
QRect m_displayRect;
diff --git a/src/plugins/mediaservices/qt7/qt7movieviewoutput.mm b/src/plugins/mediaservices/qt7/qt7movieviewoutput.mm
index d8dbf9b..8e4dd9b 100644
--- a/src/plugins/mediaservices/qt7/qt7movieviewoutput.mm
+++ b/src/plugins/mediaservices/qt7/qt7movieviewoutput.mm
@@ -154,6 +154,7 @@ QT7MovieViewOutput::QT7MovieViewOutput(QObject *parent)
:QT7VideoWindowControl(parent),
m_movie(0),
m_movieView(0),
+ m_layouted(false),
m_winId(0),
m_fullscreen(false),
m_aspectRatioMode(Qt::KeepAspectRatio),
@@ -166,6 +167,8 @@ QT7MovieViewOutput::QT7MovieViewOutput(QObject *parent)
QT7MovieViewOutput::~QT7MovieViewOutput()
{
+ [(QTMovieView*)m_movieView release];
+ [(QTMovie*)m_movie release];
}
void QT7MovieViewOutput::setupVideoOutput()
@@ -186,6 +189,7 @@ void QT7MovieViewOutput::setupVideoOutput()
[(QTMovieView*)m_movieView setMovie:(QTMovie*)m_movie];
[(NSView *)m_winId addSubview:(QTMovieView*)m_movieView];
+ m_layouted = true;
setDisplayRect(m_displayRect);
}
@@ -196,8 +200,21 @@ void QT7MovieViewOutput::setEnabled(bool)
void QT7MovieViewOutput::setMovie(void *movie)
{
- m_movie = movie;
- setupVideoOutput();
+ if (m_movie != movie) {
+ if (m_movie) {
+ if (m_movieView)
+ [(QTMovieView*)m_movieView setMovie:nil];
+
+ [(QTMovie*)m_movie release];
+ }
+
+ m_movie = movie;
+
+ if (m_movie)
+ [(QTMovie*)m_movie retain];
+
+ setupVideoOutput();
+ }
}
void QT7MovieViewOutput::updateNaturalSize(const QSize &newSize)
@@ -215,8 +232,15 @@ WId QT7MovieViewOutput::winId() const
void QT7MovieViewOutput::setWinId(WId id)
{
- m_winId = id;
- setupVideoOutput();
+ if (m_winId != id) {
+ if (m_movieView && m_layouted) {
+ [(QTMovieView*)m_movieView removeFromSuperview];
+ m_layouted = false;
+ }
+
+ m_winId = id;
+ setupVideoOutput();
+ }
}
QRect QT7MovieViewOutput::displayRect() const