summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrody <brody@ieee.org>2013-12-11 05:46:04 (GMT)
committerBrody <brody@ieee.org>2013-12-11 05:46:04 (GMT)
commitef92a395a8498230921fe3d5edb694c2388fdbb9 (patch)
tree1d51892f9cf9b61fdf01eac2f8e95a6e32c54a1d
parentd7d5bea7363703c76b9787598304bfc838e893ee (diff)
parent50fb5bb135f62ed56230d8b8afd691284616b4f6 (diff)
Merge pull request #1 from openscad/brodykenrick-master
Brodykenrick master
-rw-r--r--patches/qt4/patch-libtiff.diff18
-rw-r--r--patches/qt4/patch-qeventdispatcher.diff86
-rw-r--r--patches/qt4/patch-qfontdatabase.diff29
-rw-r--r--patches/qt4/patch-src_corelib_global_qglobal.h.diff14
-rw-r--r--patches/qt4/patch-src_plugins_bearer_corewlan_qcorewlanengine.mm.diff1382
-rwxr-xr-xscripts/macosx-build-dependencies.sh43
-rw-r--r--src/CocoaUtils.mm4
-rw-r--r--src/PolySetCGALEvaluator.cc9
-rw-r--r--src/modcontext.cc2
-rw-r--r--src/openscad.cc7
-rw-r--r--src/stl-utils.cc2
-rw-r--r--tests/CMakeLists.txt36
-rw-r--r--tests/FindGLIB2.cmake27
13 files changed, 1625 insertions, 34 deletions
diff --git a/patches/qt4/patch-libtiff.diff b/patches/qt4/patch-libtiff.diff
new file mode 100644
index 0000000..5b7f9ec
--- /dev/null
+++ b/patches/qt4/patch-libtiff.diff
@@ -0,0 +1,18 @@
+--- src/3rdparty/libtiff/libtiff/tif_config.h
++++ src/3rdparty/libtiff/libtiff/tif_config.h
+@@ -317,15 +317,6 @@
+ /* Define to empty if `const' does not conform to ANSI C. */
+ /* #undef const */
+
+-/* Define to `__inline__' or `__inline' if that's what the C compiler
+- calls it, or to nothing if 'inline' is not supported under any name. */
+-#ifndef Q_OS_SYMBIAN
+-#ifndef __cplusplus
+-#undef inline
+-#define inline
+-#endif
+-#endif
+-
+ /* Define to `long int' if <sys/types.h> does not define. */
+ /* #undef off_t */
+
diff --git a/patches/qt4/patch-qeventdispatcher.diff b/patches/qt4/patch-qeventdispatcher.diff
new file mode 100644
index 0000000..89ed478
--- /dev/null
+++ b/patches/qt4/patch-qeventdispatcher.diff
@@ -0,0 +1,86 @@
+--- src/gui/kernel/qeventdispatcher_mac_p.h 2013-06-07 01:16:59.000000000 -0400
++++ src/gui/kernel/qeventdispatcher_mac_p_new-8184b49c12d887928921ed5b695c8c6f04a07514.h 2013-12-08 14:31:01.000000000 -0500
+@@ -173,6 +173,7 @@
+ #ifdef QT_MAC_USE_COCOA
+ // The following variables help organizing modal sessions:
+ static QStack<QCocoaModalSessionInfo> cocoaModalSessionStack;
++ static QStack<QCocoaModalSessionInfo> cocoaModalSessionStackPendingEnd;
+ static bool currentExecIsNSAppRun;
+ static bool nsAppRunCalledByQt;
+ static bool cleanupModalSessionsNeeded;
+@@ -180,6 +181,7 @@
+ static NSModalSession currentModalSession();
+ static void updateChildrenWorksWhenModal();
+ static void temporarilyStopAllModalSessions();
++ static void stopAllPendingEndModalSessions();
+ static void beginModalSession(QWidget *widget);
+ static void endModalSession(QWidget *widget);
+ static void cancelWaitForMoreEvents();
+--- src/gui/kernel/qeventdispatcher_mac.mm 2013-06-07 01:16:59.000000000 -0400
++++ src/gui/kernel/qeventdispatcher_mac_new-833e02de99494686f8dd7a567f6e19e847508f11.mm 2013-12-08 14:30:59.000000000 -0500
+@@ -603,6 +603,9 @@
+ while ([NSApp runModalSession:session] == NSRunContinuesResponse && !d->interrupt)
+ qt_mac_waitForMoreModalSessionEvents();
+
++ // stop all pending end modal sessions
++ d->stopAllPendingEndModalSessions();
++
+ if (!d->interrupt && session == d->currentModalSessionCached) {
+ // Someone called [NSApp stopModal:] from outside the event
+ // dispatcher (e.g to stop a native dialog). But that call wrongly stopped
+@@ -678,6 +681,9 @@
+ if (!d->interrupt)
+ QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData);
+
++ // stop all pending end modal sessions
++ d->stopAllPendingEndModalSessions();
++
+ // Since the window that holds modality might have changed while processing
+ // events, we we need to interrupt when we return back the previous process
+ // event recursion to ensure that we spin the correct modal session.
+@@ -781,6 +787,7 @@
+
+ #ifdef QT_MAC_USE_COCOA
+ QStack<QCocoaModalSessionInfo> QEventDispatcherMacPrivate::cocoaModalSessionStack;
++QStack<QCocoaModalSessionInfo> QEventDispatcherMacPrivate::cocoaModalSessionStackPendingEnd;
+ bool QEventDispatcherMacPrivate::currentExecIsNSAppRun = false;
+ bool QEventDispatcherMacPrivate::nsAppRunCalledByQt = false;
+ bool QEventDispatcherMacPrivate::cleanupModalSessionsNeeded = false;
+@@ -828,6 +835,20 @@
+ currentModalSessionCached = 0;
+ }
+
++void QEventDispatcherMacPrivate::stopAllPendingEndModalSessions()
++{
++ // stop all modal sessions pending end
++ int stackSize = cocoaModalSessionStackPendingEnd.size();
++ for (int i=stackSize-1; i>=0; --i) {
++ QCocoaModalSessionInfo &info = cocoaModalSessionStackPendingEnd[i];
++ cocoaModalSessionStackPendingEnd.remove(i);
++ if (info.session) {
++ [NSApp endModalSession:info.session];
++ [(NSWindow *)info.nswindow release];
++ }
++ }
++}
++
+ NSModalSession QEventDispatcherMacPrivate::currentModalSession()
+ {
+ // If we have one or more modal windows, this function will create
+@@ -925,10 +946,12 @@
+ }
+ cocoaModalSessionStack.remove(i);
+ currentModalSessionCached = 0;
+- if (info.session) {
+- [NSApp endModalSession:info.session];
+- [(NSWindow *)info.nswindow release];
+- }
++
++ // Cannot stop the sessions here since we might still be inside a
++ // [NSApp runModalSession:] call. Add the session to the pending end stack and
++ // process the stack after the call to [NSApp runModalSession:] returns.
++ if (info.session)
++ cocoaModalSessionStackPendingEnd.push(info);
+ }
+
+ updateChildrenWorksWhenModal();
diff --git a/patches/qt4/patch-qfontdatabase.diff b/patches/qt4/patch-qfontdatabase.diff
new file mode 100644
index 0000000..c078890
--- /dev/null
+++ b/patches/qt4/patch-qfontdatabase.diff
@@ -0,0 +1,29 @@
+--- src/gui/text/qfontdatabase.cpp 2013-06-07 01:16:59.000000000 -0400
++++ src/gui/text/qfontdatabase_new-bb2beddc3ae55c4676d190d0ac99aa32d322a6a5.cpp 2013-12-08 14:51:10.000000000 -0500
+@@ -441,6 +441,7 @@
+ #endif
+ #if !defined(QWS) && defined(Q_OS_MAC)
+ bool fixedPitchComputed : 1;
++ QString postscriptName;
+ #endif
+ #ifdef Q_WS_X11
+ bool symbol_checked : 1;
+--- src/gui/text/qfontdatabase_mac.cpp 2013-06-07 01:16:59.000000000 -0400
++++ src/gui/text/qfontdatabase_mac_new-41f29865db84152efb41c048470f713353a0a84c.cpp 2013-12-08 14:51:05.000000000 -0500
+@@ -147,6 +147,7 @@
+ QCFString family_name = (CFStringRef)CTFontDescriptorCopyLocalizedAttribute(font, kCTFontFamilyNameAttribute, NULL);
+ QCFString style_name = (CFStringRef)CTFontDescriptorCopyLocalizedAttribute(font, kCTFontStyleNameAttribute, NULL);
+ QtFontFamily *family = db->family(family_name, true);
++ family->postscriptName = QCFString((CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontNameAttribute));
+
+ if (QCFType<CFArrayRef> languages = (CFArrayRef) CTFontDescriptorCopyAttribute(font, kCTFontLanguagesAttribute)) {
+ CFIndex length = CFArrayGetCount(languages);
+@@ -327,7 +328,7 @@
+ if (db->families[k]->name.compare(family_list.at(i), Qt::CaseInsensitive) == 0) {
+ QByteArray family_name = db->families[k]->name.toUtf8();
+ #if defined(QT_MAC_USE_COCOA)
+- QCFType<CTFontRef> ctFont = CTFontCreateWithName(QCFString(db->families[k]->name), 12, NULL);
++ QCFType<CTFontRef> ctFont = CTFontCreateWithName(QCFString(db->families[k]->postscriptName), 12, NULL);
+ if (ctFont) {
+ fontName = CTFontCopyFullName(ctFont);
+ goto found;
diff --git a/patches/qt4/patch-src_corelib_global_qglobal.h.diff b/patches/qt4/patch-src_corelib_global_qglobal.h.diff
new file mode 100644
index 0000000..8c55c5a
--- /dev/null
+++ b/patches/qt4/patch-src_corelib_global_qglobal.h.diff
@@ -0,0 +1,14 @@
+--- src/corelib/global/qglobal.h.orig 2013-06-07 07:16:52.000000000 +0200
++++ src/corelib/global/qglobal.h 2013-10-27 14:05:22.000000000 +0100
+@@ -327,7 +327,10 @@
+ # if !defined(MAC_OS_X_VERSION_10_8)
+ # define MAC_OS_X_VERSION_10_8 MAC_OS_X_VERSION_10_7 + 1
+ # endif
+-# if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_8)
++# if !defined(MAC_OS_X_VERSION_10_9)
++# define MAC_OS_X_VERSION_10_9 MAC_OS_X_VERSION_10_8 + 1
++# endif
++# if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_9)
+ # warning "This version of Mac OS X is unsupported"
+ # endif
+ #endif
diff --git a/patches/qt4/patch-src_plugins_bearer_corewlan_qcorewlanengine.mm.diff b/patches/qt4/patch-src_plugins_bearer_corewlan_qcorewlanengine.mm.diff
new file mode 100644
index 0000000..61b2eef
--- /dev/null
+++ b/patches/qt4/patch-src_plugins_bearer_corewlan_qcorewlanengine.mm.diff
@@ -0,0 +1,1382 @@
+--- src/plugins/bearer/corewlan/qcorewlanengine.mm
++++ src/plugins/bearer/corewlan/qcorewlanengine.mm
+@@ -52,29 +52,17 @@
+ #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>
+-#include <Foundation/NSAutoreleasePool.h>
+-#include <Foundation/NSLock.h>
+-
+-#include <SystemConfiguration/SCNetworkConfiguration.h>
++
++extern "C" { // Otherwise it won't find CWKeychain* symbols at link time
++#import <CoreWLAN/CoreWLAN.h>
++}
++
+ #include "private/qcore_mac_p.h"
+
+ #include <net/if.h>
+ #include <ifaddrs.h>
+
+-inline QString qt_NSStringToQString(const NSString *nsstr)
+-{ return QCFString::toQString(reinterpret_cast<const CFStringRef>(nsstr)); }
+-
+-inline NSString *qt_QStringToNSString(const QString &qstr)
+-{ return [const_cast<NSString *>(reinterpret_cast<const NSString *>(QCFString::toCFStringRef(qstr))) autorelease]; }
+-
++#if __MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
+
+ @interface QT_MANGLE_NAMESPACE(QNSListener) : NSObject
+ {
+@@ -86,6 +74,7 @@ inline NSString *qt_QStringToNSString(const QString &qstr)
+ - (void)notificationHandler;//:(NSNotification *)notification;
+ - (void)remove;
+ - (void)setEngine:(QCoreWlanEngine *)coreEngine;
++- (QCoreWlanEngine *)engine;
+ - (void)dealloc;
+
+ @property (assign) QCoreWlanEngine* engine;
+@@ -93,7 +82,6 @@ inline NSString *qt_QStringToNSString(const QString &qstr)
+ @end
+
+ @implementation QT_MANGLE_NAMESPACE(QNSListener)
+-@synthesize engine;
+
+ - (id) init
+ {
+@@ -101,7 +89,7 @@ inline NSString *qt_QStringToNSString(const QString &qstr)
+ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ notificationCenter = [NSNotificationCenter defaultCenter];
+ currentInterface = [CWInterface interfaceWithName:nil];
+- [notificationCenter addObserver:self selector:@selector(notificationHandler:) name:kCWPowerDidChangeNotification object:nil];
++ [notificationCenter addObserver:self selector:@selector(notificationHandler:) name:CWPowerDidChangeNotification object:nil];
+ [locker unlock];
+ [autoreleasepool release];
+ return self;
+@@ -120,6 +108,11 @@ inline NSString *qt_QStringToNSString(const QString &qstr)
+ [locker unlock];
+ }
+
++-(QCoreWlanEngine *)engine
++{
++ return engine;
++}
++
+ -(void)remove
+ {
+ [locker lock];
+@@ -133,7 +126,7 @@ inline NSString *qt_QStringToNSString(const QString &qstr)
+ }
+ @end
+
+-QT_MANGLE_NAMESPACE(QNSListener) *listener = 0;
++static QT_MANGLE_NAMESPACE(QNSListener) *listener = 0;
+
+ QT_BEGIN_NAMESPACE
+
+@@ -170,36 +163,28 @@ void QScanThread::run()
+ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ QStringList found;
+ mutex.lock();
+- CWInterface *currentInterface = [CWInterface interfaceWithName:qt_QStringToNSString(interfaceName)];
++ CWInterface *currentInterface = [CWInterface interfaceWithName: (NSString *)QCFString::toCFStringRef(interfaceName)];
+ mutex.unlock();
+
+- if([currentInterface power]) {
++ if (currentInterface.powerOn) {
+ NSError *err = nil;
+- NSDictionary *parametersDict = [NSDictionary dictionaryWithObjectsAndKeys:
+- [NSNumber numberWithBool:YES], kCWScanKeyMerge,
+- [NSNumber numberWithInt:kCWScanTypeFast], kCWScanKeyScanType,
+- [NSNumber numberWithInteger:100], kCWScanKeyRestTime, nil];
+
+- NSArray* apArray = [currentInterface scanForNetworksWithParameters:parametersDict error:&err];
+- CWNetwork *apNetwork;
++ NSSet* apSet = [currentInterface scanForNetworksWithName:nil error:&err];
+
+ if (!err) {
+-
+- for(uint row=0; row < [apArray count]; row++ ) {
+- apNetwork = [apArray objectAtIndex:row];
+-
+- const QString networkSsid = qt_NSStringToQString([apNetwork ssid]);
++ for (CWNetwork *apNetwork in apSet) {
++ const QString networkSsid = QCFString::toQString(CFStringRef([apNetwork ssid]));
+ const QString id = QString::number(qHash(QLatin1String("corewlan:") + networkSsid));
+ found.append(id);
+
+ QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined;
+ bool known = isKnownSsid(networkSsid);
+- if( [currentInterface.interfaceState intValue] == kCWInterfaceStateRunning) {
+- if( networkSsid == qt_NSStringToQString( [currentInterface ssid])) {
++ if (currentInterface.serviceActive) {
++ if( networkSsid == QCFString::toQString(CFStringRef([currentInterface ssid]))) {
+ state = QNetworkConfiguration::Active;
+ }
+ }
+- if(state == QNetworkConfiguration::Undefined) {
++ if (state == QNetworkConfiguration::Undefined) {
+ if(known) {
+ state = QNetworkConfiguration::Discovered;
+ } else {
+@@ -207,7 +192,7 @@ void QScanThread::run()
+ }
+ }
+ QNetworkConfiguration::Purpose purpose = QNetworkConfiguration::UnknownPurpose;
+- if([[apNetwork securityMode] intValue] == kCWSecurityModeOpen) {
++ if ([apNetwork supportsSecurity:kCWSecurityNone]) {
+ purpose = QNetworkConfiguration::PublicPurpose;
+ } else {
+ purpose = QNetworkConfiguration::PrivatePurpose;
+@@ -237,8 +222,8 @@ void QScanThread::run()
+ interfaceName = ij.value();
+ }
+
+- if( [currentInterface.interfaceState intValue] == kCWInterfaceStateRunning) {
+- if( networkSsid == qt_NSStringToQString([currentInterface ssid])) {
++ if (currentInterface.serviceActive) {
++ if( networkSsid == QCFString::toQString(CFStringRef([currentInterface ssid]))) {
+ state = QNetworkConfiguration::Active;
+ }
+ }
+@@ -300,14 +285,14 @@ void QScanThread::getUserConfigurations()
+ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+ userProfiles.clear();
+
+- NSArray *wifiInterfaces = [CWInterface supportedInterfaces];
+- for(uint row=0; row < [wifiInterfaces count]; row++ ) {
++ NSSet *wifiInterfaces = [CWInterface interfaceNames];
++ for (NSString *ifName in wifiInterfaces) {
+
+- CWInterface *wifiInterface = [CWInterface interfaceWithName: [wifiInterfaces objectAtIndex:row]];
+- if ( ![wifiInterface power] )
++ CWInterface *wifiInterface = [CWInterface interfaceWithName: ifName];
++ if (!wifiInterface.powerOn)
+ continue;
+
+- NSString *nsInterfaceName = [wifiInterface name];
++ NSString *nsInterfaceName = wifiInterface.ssid;
+ // 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]);
+@@ -316,11 +301,11 @@ void QScanThread::getUserConfigurations()
+ NSDictionary *prefNetDict = [airportPlist objectForKey:@"PreferredNetworks"];
+
+ NSArray *thisSsidarray = [prefNetDict valueForKey:@"SSID_STR"];
+- for(NSString *ssidkey in thisSsidarray) {
+- QString thisSsid = qt_NSStringToQString(ssidkey);
++ for (NSString *ssidkey in thisSsidarray) {
++ QString thisSsid = QCFString::toQString(CFStringRef(ssidkey));
+ if(!userProfiles.contains(thisSsid)) {
+ QMap <QString,QString> map;
+- map.insert(thisSsid, qt_NSStringToQString(nsInterfaceName));
++ map.insert(thisSsid, QCFString::toQString(CFStringRef(nsInterfaceName)));
+ userProfiles.insert(thisSsid, map);
+ }
+ }
+@@ -329,7 +314,7 @@ void QScanThread::getUserConfigurations()
+
+ // 802.1X user profiles
+ QString userProfilePath = QDir::homePath() + "/Library/Preferences/com.apple.eap.profiles.plist";
+- NSDictionary* eapDict = [[[NSDictionary alloc] initWithContentsOfFile:qt_QStringToNSString(userProfilePath)] autorelease];
++ NSDictionary* eapDict = [[[NSDictionary alloc] initWithContentsOfFile: (NSString *)QCFString::toCFStringRef(userProfilePath)] autorelease];
+ if(eapDict != nil) {
+ NSString *profileStr= @"Profiles";
+ NSString *nameStr = @"UserDefinedName";
+@@ -348,15 +333,15 @@ void QScanThread::getUserConfigurations()
+ QString ssid;
+ for(int i = 0; i < dictSize; i++) {
+ if([nameStr isEqualToString:keys[i]]) {
+- networkName = qt_NSStringToQString(objects[i]);
++ networkName = QCFString::toQString(CFStringRef(objects[i]));
+ }
+ if([networkSsidStr isEqualToString:keys[i]]) {
+- ssid = qt_NSStringToQString(objects[i]);
++ ssid = QCFString::toQString(CFStringRef(objects[i]));
+ }
+ if(!userProfiles.contains(networkName)
+ && !ssid.isEmpty()) {
+ QMap<QString,QString> map;
+- map.insert(ssid, qt_NSStringToQString(nsInterfaceName));
++ map.insert(ssid, QCFString::toQString(CFStringRef(nsInterfaceName)));
+ userProfiles.insert(networkName, map);
+ }
+ }
+@@ -444,7 +429,7 @@ void QCoreWlanEngine::initialize()
+ QMutexLocker locker(&mutex);
+ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+
+- if([[CWInterface supportedInterfaces] count] > 0 && !listener) {
++ if ([[CWInterface interfaceNames] count] > 0 && !listener) {
+ listener = [[QT_MANGLE_NAMESPACE(QNSListener) alloc] init];
+ listener.engine = this;
+ hasWifi = true;
+@@ -479,141 +464,68 @@ void QCoreWlanEngine::connectToId(const QString &id)
+ QString interfaceString = getInterfaceFromId(id);
+
+ CWInterface *wifiInterface =
+- [CWInterface interfaceWithName: qt_QStringToNSString(interfaceString)];
++ [CWInterface interfaceWithName: (NSString *)QCFString::toCFStringRef(interfaceString)];
+
+- if ([wifiInterface power]) {
++ if (wifiInterface.powerOn) {
+ NSError *err = nil;
+- NSMutableDictionary *params = [NSMutableDictionary dictionaryWithCapacity:0];
+-
+ QString wantedSsid;
+-
+ QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
+
+ const QString idHash = QString::number(qHash(QLatin1String("corewlan:") + ptr->name));
+ const QString idHash2 = QString::number(qHash(QLatin1String("corewlan:") + scanThread->getNetworkNameFromSsid(ptr->name)));
+
+- bool using8021X = false;
+- if (idHash2 != id) {
+- NSArray *array = [CW8021XProfile allUser8021XProfiles];
+-
+- for (NSUInteger i = 0; i < [array count]; ++i) {
+- const QString networkNameHashCheck = QString::number(qHash(QLatin1String("corewlan:") + qt_NSStringToQString([[array objectAtIndex:i] userDefinedName])));
+-
+- const QString ssidHash = QString::number(qHash(QLatin1String("corewlan:") + qt_NSStringToQString([[array objectAtIndex:i] ssid])));
+-
+- if (id == networkNameHashCheck || id == ssidHash) {
+- const QString thisName = scanThread->getSsidFromNetworkName(id);
+- if (thisName.isEmpty())
+- wantedSsid = id;
+- else
+- wantedSsid = thisName;
+-
+- [params setValue: [array objectAtIndex:i] forKey:kCWAssocKey8021XProfile];
+- using8021X = true;
+- break;
+- }
++ QString wantedNetwork;
++ QMapIterator<QString, QMap<QString, QString> > i(scanThread->userProfiles);
++ while (i.hasNext()) {
++ i.next();
++ wantedNetwork = i.key();
++ const QString networkNameHash = QString::number(qHash(QLatin1String("corewlan:") + wantedNetwork));
++ if (id == networkNameHash) {
++ wantedSsid = scanThread->getSsidFromNetworkName(wantedNetwork);
++ break;
+ }
+ }
+
+- if (!using8021X) {
+- QString wantedNetwork;
+- QMapIterator<QString, QMap<QString,QString> > i(scanThread->userProfiles);
+- while (i.hasNext()) {
+- i.next();
+- wantedNetwork = i.key();
+- const QString networkNameHash = QString::number(qHash(QLatin1String("corewlan:") + wantedNetwork));
+- if (id == networkNameHash) {
+- wantedSsid = scanThread->getSsidFromNetworkName(wantedNetwork);
+- break;
+- }
+- }
+- }
+- NSDictionary *scanParameters = [NSDictionary dictionaryWithObjectsAndKeys:
+- [NSNumber numberWithBool:YES], kCWScanKeyMerge,
+- [NSNumber numberWithInt:kCWScanTypeFast], kCWScanKeyScanType,
+- [NSNumber numberWithInteger:100], kCWScanKeyRestTime,
+- qt_QStringToNSString(wantedSsid), kCWScanKeySSID,
+- nil];
+-
+- NSArray *scanArray = [wifiInterface scanForNetworksWithParameters:scanParameters error:&err];
++ NSSet *scanSet = [wifiInterface scanForNetworksWithName:(NSString *)QCFString::toCFStringRef(wantedSsid) error:&err];
+
+ if(!err) {
+- for(uint row=0; row < [scanArray count]; row++ ) {
+- CWNetwork *apNetwork = [scanArray objectAtIndex:row];
+-
+- if(wantedSsid == qt_NSStringToQString([apNetwork ssid])) {
+-
+- if(!using8021X) {
+- SecKeychainAttribute attributes[3];
+-
+- NSString *account = [apNetwork ssid];
+- NSString *keyKind = @"AirPort network password";
+- NSString *keyName = account;
+-
+- attributes[0].tag = kSecAccountItemAttr;
+- attributes[0].data = (void *)[account UTF8String];
+- attributes[0].length = [account length];
+-
+- attributes[1].tag = kSecDescriptionItemAttr;
+- attributes[1].data = (void *)[keyKind UTF8String];
+- attributes[1].length = [keyKind length];
+-
+- attributes[2].tag = kSecLabelItemAttr;
+- attributes[2].data = (void *)[keyName UTF8String];
+- attributes[2].length = [keyName length];
+-
+- SecKeychainAttributeList attributeList = {3,attributes};
+-
+- SecKeychainSearchRef searchRef;
+- SecKeychainSearchCreateFromAttributes(NULL, kSecGenericPasswordItemClass, &attributeList, &searchRef);
+-
+- NSString *password = @"";
+- SecKeychainItemRef searchItem;
+-
+- if (SecKeychainSearchCopyNext(searchRef, &searchItem) == noErr) {
+- UInt32 realPasswordLength;
+- SecKeychainAttribute attributesW[8];
+- attributesW[0].tag = kSecAccountItemAttr;
+- SecKeychainAttributeList listW = {1,attributesW};
+- char *realPassword;
+- OSStatus status = SecKeychainItemCopyContent(searchItem, NULL, &listW, &realPasswordLength,(void **)&realPassword);
+-
+- if (status == noErr) {
+- if (realPassword != NULL) {
+-
+- QByteArray pBuf;
+- pBuf.resize(realPasswordLength);
+- pBuf.prepend(realPassword);
+- pBuf.insert(realPasswordLength,'\0');
+-
+- password = [NSString stringWithUTF8String:pBuf];
+- }
+- SecKeychainItemFreeContent(&listW, realPassword);
+- }
+-
+- CFRelease(searchItem);
+- } else {
+- qDebug() << "SecKeychainSearchCopyNext error";
+- }
+- [params setValue: password forKey: kCWAssocKeyPassphrase];
+- } // end using8021X
+-
+-
+- bool result = [wifiInterface associateToNetwork: apNetwork parameters:[NSDictionary dictionaryWithDictionary:params] error:&err];
++ for (CWNetwork *apNetwork in scanSet) {
++ CFDataRef ssidData = (CFDataRef)[apNetwork ssidData];
++ bool result = false;
++
++ SecIdentityRef identity = 0;
++ // Check first whether we require IEEE 802.1X authentication for the wanted SSID
++ if (CWKeychainCopyEAPIdentity(ssidData, &identity) == errSecSuccess) {
++ CFStringRef username = 0;
++ CFStringRef password = 0;
++ if (CWKeychainCopyEAPUsernameAndPassword(ssidData, &username, &password) == errSecSuccess) {
++ result = [wifiInterface associateToEnterpriseNetwork:apNetwork
++ identity:identity username:(NSString *)username password:(NSString *)password
++ error:&err];
++ CFRelease(username);
++ CFRelease(password);
++ }
++ CFRelease(identity);
++ } else {
++ CFStringRef password = 0;
++ if (CWKeychainCopyPassword(ssidData, &password) == errSecSuccess) {
++ result = [wifiInterface associateToNetwork:apNetwork password:(NSString *)password error:&err];
++ CFRelease(password);
++ }
++ }
+
+- if(!err) {
+- if(!result) {
+- emit connectionError(id, ConnectError);
+- } else {
+- return;
+- }
++ if (!err) {
++ if (!result) {
++ emit connectionError(id, ConnectError);
+ } else {
+- qDebug() <<"associate ERROR"<< qt_NSStringToQString([err localizedDescription ]);
++ return;
+ }
++ } else {
++ qDebug() <<"associate ERROR"<< QCFString::toQString(CFStringRef([err localizedDescription ]));
+ }
+ } //end scan network
+ } else {
+- qDebug() <<"scan ERROR"<< qt_NSStringToQString([err localizedDescription ]);
++ qDebug() <<"scan ERROR"<< QCFString::toQString(CFStringRef([err localizedDescription ]));
+ }
+ emit connectionError(id, InterfaceLookupError);
+ }
+@@ -631,10 +543,10 @@ void QCoreWlanEngine::disconnectFromId(const QString &id)
+ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+
+ CWInterface *wifiInterface =
+- [CWInterface interfaceWithName: qt_QStringToNSString(interfaceString)];
++ [CWInterface interfaceWithName: (NSString *)QCFString::toCFStringRef(interfaceString)];
+
+ [wifiInterface disassociate];
+- if ([[wifiInterface interfaceState]intValue] != kCWInterfaceStateInactive) {
++ if (wifiInterface.serviceActive) {
+ locker.unlock();
+ emit connectionError(id, DisconnectionError);
+ locker.relock();
+@@ -654,9 +566,9 @@ void QCoreWlanEngine::doRequestUpdate()
+
+ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+
+- NSArray *wifiInterfaces = [CWInterface supportedInterfaces];
+- for (uint row = 0; row < [wifiInterfaces count]; ++row) {
+- scanThread->interfaceName = qt_NSStringToQString([wifiInterfaces objectAtIndex:row]);
++ NSSet *wifiInterfaces = [CWInterface interfaceNames];
++ for (NSString *ifName in wifiInterfaces) {
++ scanThread->interfaceName = QCFString::toQString(CFStringRef(ifName));
+ scanThread->start();
+ }
+ locker.unlock();
+@@ -669,8 +581,8 @@ bool QCoreWlanEngine::isWifiReady(const QString &wifiDeviceName)
+ bool haswifi = false;
+ if(hasWifi) {
+ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+- CWInterface *defaultInterface = [CWInterface interfaceWithName: qt_QStringToNSString(wifiDeviceName)];
+- if([defaultInterface power]) {
++ CWInterface *defaultInterface = [CWInterface interfaceWithName: (NSString *)QCFString::toCFStringRef(wifiDeviceName)];
++ if (defaultInterface.powerOn) {
+ haswifi = true;
+ }
+ [autoreleasepool release];
+@@ -898,7 +810,7 @@ quint64 QCoreWlanEngine::startTime(const QString &identifier)
+ bool ok = false;
+ for(int i = 0; i < dictSize; i++) {
+ if([ssidStr isEqualToString:keys[i]]) {
+- const QString ident = QString::number(qHash(QLatin1String("corewlan:") + qt_NSStringToQString(objects[i])));
++ const QString ident = QString::number(qHash(QLatin1String("corewlan:") + QCFString::toQString(CFStringRef(objects[i]))));
+ if(ident == identifier) {
+ ok = true;
+ }
+@@ -944,3 +856,7 @@ quint64 QCoreWlanEngine::getBytes(const QString &interfaceName, bool b)
+ }
+
+ QT_END_NAMESPACE
++
++#else // QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE
++#include "qcorewlanengine_10_6.mm"
++#endif
+diff --git a/src/plugins/bearer/corewlan/qcorewlanengine_10_6.mm b/src/plugins/bearer/corewlan/qcorewlanengine_10_6.mm
+new file mode 100644
+index 0000000..a3bf615
+--- /dev/null
++++ src/plugins/bearer/corewlan/qcorewlanengine_10_6.mm
+@@ -0,0 +1,916 @@
++/****************************************************************************
++**
++** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
++** Contact: http://www.qt-project.org/legal
++**
++** This file is part of the plugins of the Qt Toolkit.
++**
++** $QT_BEGIN_LICENSE:LGPL$
++** Commercial License Usage
++** Licensees holding valid commercial Qt licenses may use this file in
++** accordance with the commercial license agreement provided with the
++** Software or, alternatively, in accordance with the terms contained in
++** a written agreement between you and Digia. For licensing terms and
++** conditions see http://qt.digia.com/licensing. For further information
++** use the contact form at http://qt.digia.com/contact-us.
++**
++** GNU Lesser General Public License Usage
++** Alternatively, this file may be used under the terms of the GNU Lesser
++** General Public License version 2.1 as published by the Free Software
++** Foundation and appearing in the file LICENSE.LGPL included in the
++** packaging of this file. Please review the following information to
++** ensure the GNU Lesser General Public License version 2.1 requirements
++** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
++**
++** In addition, as a special exception, Digia gives you certain additional
++** rights. These rights are described in the Digia Qt LGPL Exception
++** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
++**
++** GNU General Public License Usage
++** Alternatively, this file may be used under the terms of the GNU
++** General Public License version 3.0 as published by the Free Software
++** Foundation and appearing in the file LICENSE.GPL included in the
++** packaging of this file. Please review the following information to
++** ensure the GNU General Public License version 3.0 requirements will be
++** met: http://www.gnu.org/copyleft/gpl.html.
++**
++**
++** $QT_END_LICENSE$
++**
++****************************************************************************/
++
++#include <SystemConfiguration/SCNetworkConfiguration.h>
++
++@interface QT_MANGLE_NAMESPACE(QNSListener) : NSObject
++{
++ NSNotificationCenter *notificationCenter;
++ CWInterface *currentInterface;
++ QCoreWlanEngine *engine;
++ NSLock *locker;
++}
++- (void)notificationHandler;//:(NSNotification *)notification;
++- (void)remove;
++- (void)setEngine:(QCoreWlanEngine *)coreEngine;
++- (QCoreWlanEngine *)engine;
++- (void)dealloc;
++
++@property (assign) QCoreWlanEngine* engine;
++
++@end
++
++@implementation QT_MANGLE_NAMESPACE(QNSListener)
++
++- (id) init
++{
++ [locker lock];
++ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
++ notificationCenter = [NSNotificationCenter defaultCenter];
++ currentInterface = [CWInterface interfaceWithName:nil];
++ [notificationCenter addObserver:self selector:@selector(notificationHandler:) name:kCWPowerDidChangeNotification object:nil];
++ [locker unlock];
++ [autoreleasepool release];
++ return self;
++}
++
++-(void)dealloc
++{
++ [super dealloc];
++}
++
++-(void)setEngine:(QCoreWlanEngine *)coreEngine
++{
++ [locker lock];
++ if(!engine)
++ engine = coreEngine;
++ [locker unlock];
++}
++
++-(QCoreWlanEngine *)engine
++{
++ return engine;
++}
++
++-(void)remove
++{
++ [locker lock];
++ [notificationCenter removeObserver:self];
++ [locker unlock];
++}
++
++- (void)notificationHandler//:(NSNotification *)notification
++{
++ engine->requestUpdate();
++}
++@end
++
++static QT_MANGLE_NAMESPACE(QNSListener) *listener = 0;
++
++QT_BEGIN_NAMESPACE
++
++void networkChangeCallback(SCDynamicStoreRef/* store*/, CFArrayRef changedKeys, void *info)
++{
++ for ( long i = 0; i < CFArrayGetCount(changedKeys); i++) {
++
++ QString changed = QCFString::toQString(CFStringRef((CFStringRef)CFArrayGetValueAtIndex(changedKeys, i)));
++ if( changed.contains("/Network/Global/IPv4")) {
++ QCoreWlanEngine* wlanEngine = static_cast<QCoreWlanEngine*>(info);
++ wlanEngine->requestUpdate();
++ }
++ }
++ return;
++}
++
++
++QScanThread::QScanThread(QObject *parent)
++ :QThread(parent)
++{
++}
++
++QScanThread::~QScanThread()
++{
++}
++
++void QScanThread::quit()
++{
++ wait();
++}
++
++void QScanThread::run()
++{
++ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
++ QStringList found;
++ mutex.lock();
++ CWInterface *currentInterface = [CWInterface interfaceWithName: (NSString *)QCFString::toCFStringRef(interfaceName)];
++ mutex.unlock();
++
++ if([currentInterface power]) {
++ NSError *err = nil;
++ NSDictionary *parametersDict = [NSDictionary dictionaryWithObjectsAndKeys:
++ [NSNumber numberWithBool:YES], kCWScanKeyMerge,
++ [NSNumber numberWithInt:kCWScanTypeFast], kCWScanKeyScanType,
++ [NSNumber numberWithInteger:100], kCWScanKeyRestTime, nil];
++
++ NSArray* apArray = [currentInterface scanForNetworksWithParameters:parametersDict error:&err];
++ CWNetwork *apNetwork;
++
++ if (!err) {
++
++ for(uint row=0; row < [apArray count]; row++ ) {
++ apNetwork = [apArray objectAtIndex:row];
++
++ const QString networkSsid = QCFString::toQString(CFStringRef([apNetwork ssid]));
++ const QString id = QString::number(qHash(QLatin1String("corewlan:") + networkSsid));
++ found.append(id);
++
++ QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined;
++ bool known = isKnownSsid(networkSsid);
++ if( [currentInterface.interfaceState intValue] == kCWInterfaceStateRunning) {
++ if( networkSsid == QCFString::toQString(CFStringRef([currentInterface ssid]))) {
++ state = QNetworkConfiguration::Active;
++ }
++ }
++ if(state == QNetworkConfiguration::Undefined) {
++ if(known) {
++ state = QNetworkConfiguration::Discovered;
++ } else {
++ state = QNetworkConfiguration::Undefined;
++ }
++ }
++ QNetworkConfiguration::Purpose purpose = QNetworkConfiguration::UnknownPurpose;
++ if([[apNetwork securityMode] intValue] == kCWSecurityModeOpen) {
++ purpose = QNetworkConfiguration::PublicPurpose;
++ } else {
++ purpose = QNetworkConfiguration::PrivatePurpose;
++ }
++
++ found.append(foundNetwork(id, networkSsid, state, interfaceName, purpose));
++
++ }
++ }
++ }
++ // add known configurations that are not around.
++ QMapIterator<QString, QMap<QString,QString> > i(userProfiles);
++ while (i.hasNext()) {
++ i.next();
++
++ QString networkName = i.key();
++ const QString id = QString::number(qHash(QLatin1String("corewlan:") + networkName));
++
++ if(!found.contains(id)) {
++ 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()) {
++ ij.next();
++ interfaceName = ij.value();
++ }
++
++ if( [currentInterface.interfaceState intValue] == kCWInterfaceStateRunning) {
++ if( networkSsid == QCFString::toQString(CFStringRef([currentInterface ssid]))) {
++ state = QNetworkConfiguration::Active;
++ }
++ }
++ if(state == QNetworkConfiguration::Undefined) {
++ if( userProfiles.contains(networkName)
++ && found.contains(ssidId)) {
++ state = QNetworkConfiguration::Discovered;
++ }
++ }
++
++ if(state == QNetworkConfiguration::Undefined) {
++ state = QNetworkConfiguration::Defined;
++ }
++
++ found.append(foundNetwork(id, networkName, state, interfaceName, QNetworkConfiguration::UnknownPurpose));
++ }
++ }
++ emit networksChanged();
++ [autoreleasepool release];
++}
++
++QStringList QScanThread::foundNetwork(const QString &id, const QString &name, const QNetworkConfiguration::StateFlags state, const QString &interfaceName, const QNetworkConfiguration::Purpose purpose)
++{
++ QStringList found;
++ QMutexLocker locker(&mutex);
++ QNetworkConfigurationPrivate *ptr = new QNetworkConfigurationPrivate;
++
++ ptr->name = name;
++ ptr->isValid = true;
++ ptr->id = id;
++ ptr->state = state;
++ ptr->type = QNetworkConfiguration::InternetAccessPoint;
++ ptr->bearerType = QNetworkConfiguration::BearerWLAN;
++ ptr->purpose = purpose;
++
++ fetchedConfigurations.append( ptr);
++ configurationInterface.insert(ptr->id, interfaceName);
++
++ locker.unlock();
++ locker.relock();
++ found.append(id);
++ return found;
++}
++
++QList<QNetworkConfigurationPrivate *> QScanThread::getConfigurations()
++{
++ QMutexLocker locker(&mutex);
++
++ QList<QNetworkConfigurationPrivate *> foundConfigurations = fetchedConfigurations;
++ fetchedConfigurations.clear();
++
++ return foundConfigurations;
++}
++
++void QScanThread::getUserConfigurations()
++{
++ QMutexLocker locker(&mutex);
++
++ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
++ userProfiles.clear();
++
++ NSArray *wifiInterfaces = [CWInterface supportedInterfaces];
++ for(uint row=0; row < [wifiInterfaces count]; row++ ) {
++
++ CWInterface *wifiInterface = [CWInterface interfaceWithName: [wifiInterfaces objectAtIndex:row]];
++ if ( ![wifiInterface power] )
++ continue;
++
++ 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]);
++ CFRelease(dynRef);
++ if(airportPlist != nil) {
++ NSDictionary *prefNetDict = [airportPlist objectForKey:@"PreferredNetworks"];
++
++ NSArray *thisSsidarray = [prefNetDict valueForKey:@"SSID_STR"];
++ for(NSString *ssidkey in thisSsidarray) {
++ QString thisSsid = QCFString::toQString(CFStringRef(ssidkey));
++ if(!userProfiles.contains(thisSsid)) {
++ QMap <QString,QString> map;
++ map.insert(thisSsid, QCFString::toQString(CFStringRef(nsInterfaceName)));
++ userProfiles.insert(thisSsid, map);
++ }
++ }
++ CFRelease(airportPlist);
++ }
++
++ // 802.1X user profiles
++ QString userProfilePath = QDir::homePath() + "/Library/Preferences/com.apple.eap.profiles.plist";
++ NSDictionary* eapDict = [[[NSDictionary alloc] initWithContentsOfFile: (NSString *)QCFString::toCFStringRef(userProfilePath)] autorelease];
++ if(eapDict != nil) {
++ NSString *profileStr= @"Profiles";
++ NSString *nameStr = @"UserDefinedName";
++ NSString *networkSsidStr = @"Wireless Network";
++ for (id profileKey in eapDict) {
++ if ([profileStr isEqualToString:profileKey]) {
++ NSDictionary *itemDict = [eapDict objectForKey:profileKey];
++ for (id itemKey in itemDict) {
++
++ NSInteger dictSize = [itemKey count];
++ id objects[dictSize];
++ id keys[dictSize];
++
++ [itemKey getObjects:objects andKeys:keys];
++ QString networkName;
++ QString ssid;
++ for(int i = 0; i < dictSize; i++) {
++ if([nameStr isEqualToString:keys[i]]) {
++ networkName = QCFString::toQString(CFStringRef(objects[i]));
++ }
++ if([networkSsidStr isEqualToString:keys[i]]) {
++ ssid = QCFString::toQString(CFStringRef(objects[i]));
++ }
++ if(!userProfiles.contains(networkName)
++ && !ssid.isEmpty()) {
++ QMap<QString,QString> map;
++ map.insert(ssid, QCFString::toQString(CFStringRef(nsInterfaceName)));
++ userProfiles.insert(networkName, map);
++ }
++ }
++ }
++ }
++ }
++ }
++ }
++ [autoreleasepool release];
++}
++
++QString QScanThread::getSsidFromNetworkName(const QString &name)
++{
++ QMutexLocker locker(&mutex);
++
++ 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()) {
++ ij.next();
++ const QString networkNameHash = QString::number(qHash(QLatin1String("corewlan:") +i.key()));
++ if(name == i.key() || name == networkNameHash) {
++ return ij.key();
++ }
++ }
++ }
++ return QString();
++}
++
++QString QScanThread::getNetworkNameFromSsid(const QString &ssid)
++{
++ QMutexLocker locker(&mutex);
++
++ 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()) {
++ ij.next();
++ if(ij.key() == ssid) {
++ return i.key();
++ }
++ }
++ }
++ return QString();
++}
++
++bool QScanThread::isKnownSsid(const QString &ssid)
++{
++ QMutexLocker locker(&mutex);
++
++ QMapIterator<QString, QMap<QString,QString> > i(userProfiles);
++ while (i.hasNext()) {
++ i.next();
++ QMap<QString,QString> map = i.value();
++ if(map.keys().contains(ssid)) {
++ return true;
++ }
++ }
++ return false;
++}
++
++
++QCoreWlanEngine::QCoreWlanEngine(QObject *parent)
++: QBearerEngineImpl(parent), scanThread(0)
++{
++ scanThread = new QScanThread(this);
++ connect(scanThread, SIGNAL(networksChanged()),
++ this, SLOT(networksChanged()));
++}
++
++QCoreWlanEngine::~QCoreWlanEngine()
++{
++ while (!foundConfigurations.isEmpty())
++ delete foundConfigurations.takeFirst();
++ [listener remove];
++ [listener release];
++}
++
++void QCoreWlanEngine::initialize()
++{
++ QMutexLocker locker(&mutex);
++ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
++
++ if([[CWInterface supportedInterfaces] count] > 0 && !listener) {
++ listener = [[QT_MANGLE_NAMESPACE(QNSListener) alloc] init];
++ listener.engine = this;
++ hasWifi = true;
++ } else {
++ hasWifi = false;
++ }
++ storeSession = NULL;
++
++ startNetworkChangeLoop();
++ [autoreleasepool release];
++}
++
++
++QString QCoreWlanEngine::getInterfaceFromId(const QString &id)
++{
++ QMutexLocker locker(&mutex);
++
++ return scanThread->configurationInterface.value(id);
++}
++
++bool QCoreWlanEngine::hasIdentifier(const QString &id)
++{
++ QMutexLocker locker(&mutex);
++
++ return scanThread->configurationInterface.contains(id);
++}
++
++void QCoreWlanEngine::connectToId(const QString &id)
++{
++ QMutexLocker locker(&mutex);
++ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
++ QString interfaceString = getInterfaceFromId(id);
++
++ CWInterface *wifiInterface =
++ [CWInterface interfaceWithName: (NSString *)QCFString::toCFStringRef(interfaceString)];
++
++ if ([wifiInterface power]) {
++ NSError *err = nil;
++ NSMutableDictionary *params = [NSMutableDictionary dictionaryWithCapacity:0];
++
++ QString wantedSsid;
++
++ QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
++
++ const QString idHash = QString::number(qHash(QLatin1String("corewlan:") + ptr->name));
++ const QString idHash2 = QString::number(qHash(QLatin1String("corewlan:") + scanThread->getNetworkNameFromSsid(ptr->name)));
++
++ bool using8021X = false;
++ if (idHash2 != id) {
++ NSArray *array = [CW8021XProfile allUser8021XProfiles];
++
++ for (NSUInteger i = 0; i < [array count]; ++i) {
++ const QString networkNameHashCheck = QString::number(qHash(QLatin1String("corewlan:") + QCFString::toQString(CFStringRef([[array objectAtIndex:i] userDefinedName]))));
++
++ const QString ssidHash = QString::number(qHash(QLatin1String("corewlan:") + QCFString::toQString(CFStringRef([[array objectAtIndex:i] ssid]))));
++
++ if (id == networkNameHashCheck || id == ssidHash) {
++ const QString thisName = scanThread->getSsidFromNetworkName(id);
++ if (thisName.isEmpty())
++ wantedSsid = id;
++ else
++ wantedSsid = thisName;
++
++ [params setValue: [array objectAtIndex:i] forKey:kCWAssocKey8021XProfile];
++ using8021X = true;
++ break;
++ }
++ }
++ }
++
++ if (!using8021X) {
++ QString wantedNetwork;
++ QMapIterator<QString, QMap<QString,QString> > i(scanThread->userProfiles);
++ while (i.hasNext()) {
++ i.next();
++ wantedNetwork = i.key();
++ const QString networkNameHash = QString::number(qHash(QLatin1String("corewlan:") + wantedNetwork));
++ if (id == networkNameHash) {
++ wantedSsid = scanThread->getSsidFromNetworkName(wantedNetwork);
++ break;
++ }
++ }
++ }
++ NSDictionary *scanParameters = [NSDictionary dictionaryWithObjectsAndKeys:
++ [NSNumber numberWithBool:YES], kCWScanKeyMerge,
++ [NSNumber numberWithInt:kCWScanTypeFast], kCWScanKeyScanType,
++ [NSNumber numberWithInteger:100], kCWScanKeyRestTime,
++ (NSString *)QCFString::toCFStringRef(wantedSsid), kCWScanKeySSID,
++ nil];
++
++ NSArray *scanArray = [wifiInterface scanForNetworksWithParameters:scanParameters error:&err];
++
++ if(!err) {
++ for(uint row=0; row < [scanArray count]; row++ ) {
++ CWNetwork *apNetwork = [scanArray objectAtIndex:row];
++
++ if(wantedSsid == QCFString::toQString(CFStringRef([apNetwork ssid]))) {
++
++ if(!using8021X) {
++ SecKeychainAttribute attributes[3];
++
++ NSString *account = [apNetwork ssid];
++ NSString *keyKind = @"AirPort network password";
++ NSString *keyName = account;
++
++ attributes[0].tag = kSecAccountItemAttr;
++ attributes[0].data = (void *)[account UTF8String];
++ attributes[0].length = [account length];
++
++ attributes[1].tag = kSecDescriptionItemAttr;
++ attributes[1].data = (void *)[keyKind UTF8String];
++ attributes[1].length = [keyKind length];
++
++ attributes[2].tag = kSecLabelItemAttr;
++ attributes[2].data = (void *)[keyName UTF8String];
++ attributes[2].length = [keyName length];
++
++ SecKeychainAttributeList attributeList = {3,attributes};
++
++ SecKeychainSearchRef searchRef;
++ SecKeychainSearchCreateFromAttributes(NULL, kSecGenericPasswordItemClass, &attributeList, &searchRef);
++
++ NSString *password = @"";
++ SecKeychainItemRef searchItem;
++
++ if (SecKeychainSearchCopyNext(searchRef, &searchItem) == noErr) {
++ UInt32 realPasswordLength;
++ SecKeychainAttribute attributesW[8];
++ attributesW[0].tag = kSecAccountItemAttr;
++ SecKeychainAttributeList listW = {1,attributesW};
++ char *realPassword;
++ OSStatus status = SecKeychainItemCopyContent(searchItem, NULL, &listW, &realPasswordLength,(void **)&realPassword);
++
++ if (status == noErr) {
++ if (realPassword != NULL) {
++
++ QByteArray pBuf;
++ pBuf.resize(realPasswordLength);
++ pBuf.prepend(realPassword);
++ pBuf.insert(realPasswordLength,'\0');
++
++ password = [NSString stringWithUTF8String:pBuf];
++ }
++ SecKeychainItemFreeContent(&listW, realPassword);
++ }
++
++ CFRelease(searchItem);
++ } else {
++ qDebug() << "SecKeychainSearchCopyNext error";
++ }
++ [params setValue: password forKey: kCWAssocKeyPassphrase];
++ } // end using8021X
++
++
++ bool result = [wifiInterface associateToNetwork: apNetwork parameters:[NSDictionary dictionaryWithDictionary:params] error:&err];
++
++ if(!err) {
++ if(!result) {
++ emit connectionError(id, ConnectError);
++ } else {
++ return;
++ }
++ } else {
++ qDebug() <<"associate ERROR"<< QCFString::toQString(CFStringRef([err localizedDescription ]));
++ }
++ }
++ } //end scan network
++ } else {
++ qDebug() <<"scan ERROR"<< QCFString::toQString(CFStringRef([err localizedDescription ]));
++ }
++ emit connectionError(id, InterfaceLookupError);
++ }
++
++ locker.unlock();
++ emit connectionError(id, InterfaceLookupError);
++ [autoreleasepool release];
++}
++
++void QCoreWlanEngine::disconnectFromId(const QString &id)
++{
++ QMutexLocker locker(&mutex);
++
++ QString interfaceString = getInterfaceFromId(id);
++ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
++
++ CWInterface *wifiInterface =
++ [CWInterface interfaceWithName: (NSString *)QCFString::toCFStringRef(interfaceString)];
++
++ [wifiInterface disassociate];
++ if ([[wifiInterface interfaceState]intValue] != kCWInterfaceStateInactive) {
++ locker.unlock();
++ emit connectionError(id, DisconnectionError);
++ locker.relock();
++ }
++ [autoreleasepool release];
++}
++
++void QCoreWlanEngine::requestUpdate()
++{
++ scanThread->getUserConfigurations();
++ doRequestUpdate();
++}
++
++void QCoreWlanEngine::doRequestUpdate()
++{
++ QMutexLocker locker(&mutex);
++
++ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
++
++ NSArray *wifiInterfaces = [CWInterface supportedInterfaces];
++ for (uint row = 0; row < [wifiInterfaces count]; ++row) {
++ scanThread->interfaceName = QCFString::toQString(CFStringRef([wifiInterfaces objectAtIndex:row]));
++ scanThread->start();
++ }
++ locker.unlock();
++ [autoreleasepool release];
++}
++
++bool QCoreWlanEngine::isWifiReady(const QString &wifiDeviceName)
++{
++ QMutexLocker locker(&mutex);
++ bool haswifi = false;
++ if(hasWifi) {
++ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
++ CWInterface *defaultInterface = [CWInterface interfaceWithName: (NSString *)QCFString::toCFStringRef(wifiDeviceName)];
++ if([defaultInterface power]) {
++ haswifi = true;
++ }
++ [autoreleasepool release];
++ }
++ return haswifi;
++}
++
++
++QNetworkSession::State QCoreWlanEngine::sessionStateForId(const QString &id)
++{
++ QMutexLocker locker(&mutex);
++ QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
++
++ if (!ptr)
++ return QNetworkSession::Invalid;
++
++ if (!ptr->isValid) {
++ return QNetworkSession::Invalid;
++ } else if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
++ return QNetworkSession::Connected;
++ } else if ((ptr->state & QNetworkConfiguration::Discovered) ==
++ QNetworkConfiguration::Discovered) {
++ return QNetworkSession::Disconnected;
++ } else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined) {
++ return QNetworkSession::NotAvailable;
++ } else if ((ptr->state & QNetworkConfiguration::Undefined) ==
++ QNetworkConfiguration::Undefined) {
++ return QNetworkSession::NotAvailable;
++ }
++
++ return QNetworkSession::Invalid;
++}
++
++QNetworkConfigurationManager::Capabilities QCoreWlanEngine::capabilities() const
++{
++ return QNetworkConfigurationManager::ForcedRoaming;
++}
++
++void QCoreWlanEngine::startNetworkChangeLoop()
++{
++
++ SCDynamicStoreContext dynStoreContext = { 0, this/*(void *)storeSession*/, NULL, NULL, NULL };
++ storeSession = SCDynamicStoreCreate(NULL,
++ CFSTR("networkChangeCallback"),
++ networkChangeCallback,
++ &dynStoreContext);
++ if (!storeSession ) {
++ qWarning() << "could not open dynamic store: error:" << SCErrorString(SCError());
++ return;
++ }
++
++ CFMutableArrayRef notificationKeys;
++ notificationKeys = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
++ CFMutableArrayRef patternsArray;
++ patternsArray = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
++
++ CFStringRef storeKey;
++ storeKey = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL,
++ kSCDynamicStoreDomainState,
++ kSCEntNetIPv4);
++ CFArrayAppendValue(notificationKeys, storeKey);
++ CFRelease(storeKey);
++
++ storeKey = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL,
++ kSCDynamicStoreDomainState,
++ kSCCompAnyRegex,
++ kSCEntNetIPv4);
++ CFArrayAppendValue(patternsArray, storeKey);
++ CFRelease(storeKey);
++
++ if (!SCDynamicStoreSetNotificationKeys(storeSession , notificationKeys, patternsArray)) {
++ qWarning() << "register notification error:"<< SCErrorString(SCError());
++ CFRelease(storeSession );
++ CFRelease(notificationKeys);
++ CFRelease(patternsArray);
++ return;
++ }
++ CFRelease(notificationKeys);
++ CFRelease(patternsArray);
++
++ runloopSource = SCDynamicStoreCreateRunLoopSource(NULL, storeSession , 0);
++ if (!runloopSource) {
++ qWarning() << "runloop source error:"<< SCErrorString(SCError());
++ CFRelease(storeSession );
++ return;
++ }
++
++ CFRunLoopAddSource(CFRunLoopGetCurrent(), runloopSource, kCFRunLoopDefaultMode);
++ return;
++}
++
++QNetworkSessionPrivate *QCoreWlanEngine::createSessionBackend()
++{
++ return new QNetworkSessionPrivateImpl;
++}
++
++QNetworkConfigurationPrivatePointer QCoreWlanEngine::defaultConfiguration()
++{
++ return QNetworkConfigurationPrivatePointer();
++}
++
++bool QCoreWlanEngine::requiresPolling() const
++{
++ return true;
++}
++
++void QCoreWlanEngine::networksChanged()
++{
++ QMutexLocker locker(&mutex);
++
++ QStringList previous = accessPointConfigurations.keys();
++
++ QList<QNetworkConfigurationPrivate *> foundConfigurations = scanThread->getConfigurations();
++ while (!foundConfigurations.isEmpty()) {
++ QNetworkConfigurationPrivate *cpPriv = foundConfigurations.takeFirst();
++
++ previous.removeAll(cpPriv->id);
++
++ if (accessPointConfigurations.contains(cpPriv->id)) {
++ QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(cpPriv->id);
++
++ bool changed = false;
++
++ ptr->mutex.lock();
++
++ if (ptr->isValid != cpPriv->isValid) {
++ ptr->isValid = cpPriv->isValid;
++ changed = true;
++ }
++
++ if (ptr->name != cpPriv->name) {
++ ptr->name = cpPriv->name;
++ changed = true;
++ }
++
++ if (ptr->bearerType != cpPriv->bearerType) {
++ ptr->bearerType = cpPriv->bearerType;
++ changed = true;
++ }
++
++ if (ptr->state != cpPriv->state) {
++ ptr->state = cpPriv->state;
++ changed = true;
++ }
++
++ ptr->mutex.unlock();
++
++ if (changed) {
++ locker.unlock();
++ emit configurationChanged(ptr);
++ locker.relock();
++ }
++
++ delete cpPriv;
++ } else {
++ QNetworkConfigurationPrivatePointer ptr(cpPriv);
++
++ accessPointConfigurations.insert(ptr->id, ptr);
++
++ locker.unlock();
++ emit configurationAdded(ptr);
++ locker.relock();
++ }
++ }
++
++ while (!previous.isEmpty()) {
++ QNetworkConfigurationPrivatePointer ptr =
++ accessPointConfigurations.take(previous.takeFirst());
++
++ locker.unlock();
++ emit configurationRemoved(ptr);
++ locker.relock();
++ }
++
++ locker.unlock();
++ emit updateCompleted();
++
++}
++
++quint64 QCoreWlanEngine::bytesWritten(const QString &id)
++{
++ QMutexLocker locker(&mutex);
++ const QString interfaceStr = getInterfaceFromId(id);
++ return getBytes(interfaceStr,false);
++}
++
++quint64 QCoreWlanEngine::bytesReceived(const QString &id)
++{
++ QMutexLocker locker(&mutex);
++ const QString interfaceStr = getInterfaceFromId(id);
++ return getBytes(interfaceStr,true);
++}
++
++quint64 QCoreWlanEngine::startTime(const QString &identifier)
++{
++ QMutexLocker locker(&mutex);
++ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
++ quint64 timestamp = 0;
++
++ NSString *filePath = @"/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist";
++ NSDictionary* plistDict = [[[NSDictionary alloc] initWithContentsOfFile:filePath] autorelease];
++ if(plistDict == nil)
++ return timestamp;
++ NSString *input = @"KnownNetworks";
++ NSString *timeStampStr = @"_timeStamp";
++
++ NSString *ssidStr = @"SSID_STR";
++
++ for (id key in plistDict) {
++ if ([input isEqualToString:key]) {
++
++ NSDictionary *knownNetworksDict = [plistDict objectForKey:key];
++ if(knownNetworksDict == nil)
++ return timestamp;
++ for (id networkKey in knownNetworksDict) {
++ bool isFound = false;
++ NSDictionary *itemDict = [knownNetworksDict objectForKey:networkKey];
++ if(itemDict == nil)
++ return timestamp;
++ NSInteger dictSize = [itemDict count];
++ id objects[dictSize];
++ id keys[dictSize];
++
++ [itemDict getObjects:objects andKeys:keys];
++ bool ok = false;
++ for(int i = 0; i < dictSize; i++) {
++ if([ssidStr isEqualToString:keys[i]]) {
++ const QString ident = QString::number(qHash(QLatin1String("corewlan:") + QCFString::toQString(CFStringRef(objects[i]))));
++ if(ident == identifier) {
++ ok = true;
++ }
++ }
++ if(ok && [timeStampStr isEqualToString:keys[i]]) {
++ timestamp = (quint64)[objects[i] timeIntervalSince1970];
++ isFound = true;
++ break;
++ }
++ }
++ if(isFound)
++ break;
++ }
++ }
++ }
++ [autoreleasepool release];
++ return timestamp;
++}
++
++quint64 QCoreWlanEngine::getBytes(const QString &interfaceName, bool b)
++{
++ struct ifaddrs *ifAddressList, *ifAddress;
++ struct if_data *if_data;
++
++ quint64 bytes = 0;
++ ifAddressList = nil;
++ if(getifaddrs(&ifAddressList) == 0) {
++ for(ifAddress = ifAddressList; ifAddress; ifAddress = ifAddress->ifa_next) {
++ if(interfaceName == ifAddress->ifa_name) {
++ if_data = (struct if_data*)ifAddress->ifa_data;
++ if(b) {
++ bytes = if_data->ifi_ibytes;
++ break;
++ } else {
++ bytes = if_data->ifi_obytes;
++ break;
++ }
++ }
++ }
++ freeifaddrs(ifAddressList);
++ }
++ return bytes;
++}
++
++QT_END_NAMESPACE
diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh
index 81985bc..72403f2 100755
--- a/scripts/macosx-build-dependencies.sh
+++ b/scripts/macosx-build-dependencies.sh
@@ -24,7 +24,7 @@ BASEDIR=$PWD/../libraries
OPENSCADDIR=$PWD
SRCDIR=$BASEDIR/src
DEPLOYDIR=$BASEDIR/install
-MAC_OSX_VERSION_MIN=10.6
+MAC_OSX_VERSION_MIN=10.7
OPTION_32BIT=false
OPTION_LLVM=false
OPTION_CLANG=false
@@ -54,6 +54,9 @@ build_qt()
fi
tar xzf qt-everywhere-opensource-src-$version.tar.gz
cd qt-everywhere-opensource-src-$version
+ patch -p0 < $OPENSCADDIR/patches/qt4/patch-src_corelib_global_qglobal.h.diff
+ patch -p0 < $OPENSCADDIR/patches/qt4/patch-libtiff.diff
+ patch -p0 < $OPENSCADDIR/patches/qt4/patch-src_plugins_bearer_corewlan_qcorewlanengine.mm.diff
if $USING_CLANG; then
# FIX for clang
sed -i "" -e "s/::TabletProximityRec/TabletProximityRec/g" src/gui/kernel/qt_cocoa_helpers_mac_p.h
@@ -220,7 +223,7 @@ build_boost()
BOOST_TOOLSET="toolset=clang"
echo "using clang ;" >> tools/build/v2/user-config.jam
fi
- ./b2 -d+2 $BOOST_TOOLSET cflags="-mmacosx-version-min=$MAC_OSX_VERSION_MIN -arch x86_64 $BOOST_EXTRA_FLAGS" linkflags="-mmacosx-version-min=$MAC_OSX_VERSION_MIN -arch x86_64 $BOOST_EXTRA_FLAGS -headerpad_max_install_names" install
+ ./b2 -j6 -d+2 $BOOST_TOOLSET cflags="-mmacosx-version-min=$MAC_OSX_VERSION_MIN -arch x86_64 $BOOST_EXTRA_FLAGS" linkflags="-mmacosx-version-min=$MAC_OSX_VERSION_MIN -arch x86_64 $BOOST_EXTRA_FLAGS -headerpad_max_install_names" install
install_name_tool -id $DEPLOYDIR/lib/libboost_thread.dylib $DEPLOYDIR/lib/libboost_thread.dylib
install_name_tool -change libboost_system.dylib $DEPLOYDIR/lib/libboost_system.dylib $DEPLOYDIR/lib/libboost_thread.dylib
install_name_tool -change libboost_chrono.dylib $DEPLOYDIR/lib/libboost_chrono.dylib $DEPLOYDIR/lib/libboost_thread.dylib
@@ -282,27 +285,40 @@ build_glew()
make GLEW_DEST=$DEPLOYDIR CC=$CC CFLAGS.EXTRA="-no-cpp-precomp -dynamic -fno-common -mmacosx-version-min=$MAC_OSX_VERSION_MIN $GLEW_EXTRA_FLAGS -arch x86_64" LDFLAGS.EXTRA="-mmacosx-version-min=$MAC_OSX_VERSION_MIN $GLEW_EXTRA_FLAGS -arch x86_64" STRIP= install
}
-build_glib2()
+build_gettext()
{
- version="$1"
- maj_min_version="${version%.*}" #Drop micro
+ version=$1
+ echo "Building gettext $version..."
- if [ -e $DEPLOYDIR/lib/glib-2.0 ]; then
- echo "glib2 already installed. not building"
- return
+ cd "$BASEDIR"/src
+ rm -rf "gettext-$version"
+ if [ ! -f "glib-$version.tar.xz" ]; then
+ curl --insecure -LO "http://ftpmirror.gnu.org/gettext/gettext-$version.tar.gz"
fi
+ tar xzf "gettext-$version.tar.gz"
+ cd "gettext-$version"
+
+ ./configure --prefix="$DEPLOYDIR"
+ make -j4
+ make install
+}
+
+build_glib2()
+{
+ version=$1
+ echo "Building glib2 $version..."
- echo "Building glib2 $version..."
cd "$BASEDIR"/src
rm -rf "glib-$version"
+ maj_min_version="${version%.*}" #Drop micro
if [ ! -f "glib-$version.tar.xz" ]; then
curl --insecure -LO "http://ftp.gnome.org/pub/gnome/sources/glib/$maj_min_version/glib-$version.tar.xz"
fi
tar xJf "glib-$version.tar.xz"
cd "glib-$version"
- ./configure --prefix="$DEPLOYDIR"
- make -j$NUMCPU
+ ./configure --disable-gtk-doc --disable-man --prefix="$DEPLOYDIR" CFLAGS="-I$DEPLOYDIR/include" LDFLAGS="-L$DEPLOYDIR/lib"
+ make -j4
make install
}
@@ -470,7 +486,12 @@ build_boost 1.54.0
# NB! For CGAL, also update the actual download URL in the function
build_cgal 4.3
build_glew 1.10.0
+<<<<<<< HEAD
+build_gettext 0.18.3.1
+build_glib2 2.38.2
+=======
build_glib2 2.38.1
+>>>>>>> d7d5bea7363703c76b9787598304bfc838e893ee
build_opencsg 1.3.2
if $OPTION_DEPLOY; then
# build_sparkle andymatuschak 0ed83cf9f2eeb425d4fdd141c01a29d843970c20
diff --git a/src/CocoaUtils.mm b/src/CocoaUtils.mm
index 92640fd..9856b3d 100644
--- a/src/CocoaUtils.mm
+++ b/src/CocoaUtils.mm
@@ -8,7 +8,7 @@ void CocoaUtils::endApplication()
object:nil];
}
-void CocoaUtils::nslog(const std::string &str, void *userdata)
+void CocoaUtils::nslog(const std::string &str, void * /* userdata */)
{
- NSLog([NSString stringWithUTF8String: str.c_str()]);
+ NSLog(@"%s", str.c_str());
}
diff --git a/src/PolySetCGALEvaluator.cc b/src/PolySetCGALEvaluator.cc
index bc9206f..599fd7f 100644
--- a/src/PolySetCGALEvaluator.cc
+++ b/src/PolySetCGALEvaluator.cc
@@ -457,7 +457,14 @@ PolySet *PolySetCGALEvaluator::rotateDxfData(const RotateExtrudeNode &node, DxfD
{
double max_x = 0;
for (size_t j = 0; j < dxf.paths[i].indices.size(); j++) {
- max_x = fmax(max_x, dxf.points[dxf.paths[i].indices[j]][0]);
+ double point_x = dxf.points[dxf.paths[i].indices[j]][0];
+ if (point_x < 0) {
+ PRINT("ERROR: all points for rotate_extrude() must have non-negative X coordinates");
+ PRINTB("[Point %d on path %d has X coordinate %f]", j % i % point_x);
+ delete ps;
+ return NULL;
+ }
+ max_x = fmax(max_x, point_x);
}
int fragments = get_fragments_from_r(max_x, node.fn, node.fs, node.fa);
diff --git a/src/modcontext.cc b/src/modcontext.cc
index 5b48009..7941cf5 100644
--- a/src/modcontext.cc
+++ b/src/modcontext.cc
@@ -162,7 +162,7 @@ void ModuleContext::dump(const AbstractModule *mod, const ModuleInstantiation *i
#endif
FileContext::FileContext(const class FileModule &module, const Context *parent)
- : usedlibs(module.usedlibs), ModuleContext(parent)
+ : ModuleContext(parent), usedlibs(module.usedlibs)
{
if (!module.modulePath().empty()) this->document_path = module.modulePath();
}
diff --git a/src/openscad.cc b/src/openscad.cc
index ece6818..ab84235 100644
--- a/src/openscad.cc
+++ b/src/openscad.cc
@@ -474,6 +474,13 @@ bool QtUseGUI()
int gui(vector<string> &inputFiles, const fs::path &original_path, int argc, char ** argv)
{
+#ifdef Q_OS_MACX
+ if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_8) {
+ // fix Mac OS X 10.9 (mavericks) font issue
+ // https://bugreports.qt-project.org/browse/QTBUG-32789
+ QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande");
+ }
+#endif
QApplication app(argc, argv, true); //useGUI);
#ifdef Q_WS_MAC
app.installEventFilter(new EventFilter(&app));
diff --git a/src/stl-utils.cc b/src/stl-utils.cc
index 790fd17..027339c 100644
--- a/src/stl-utils.cc
+++ b/src/stl-utils.cc
@@ -1,4 +1,4 @@
-#if defined(__APPLE__) && defined(__GNUC__)
+#if defined(__APPLE__) && defined(__GNUC__) && !defined(__clang__)
#include <iostream>
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 65eefcd..e590070 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,6 +1,6 @@
# instructions - see ../doc/testing.txt
-# set(DEBUG_OSCD 1) # print debug info during cmake
+#set(DEBUG_OSCD 1) # print debug info during cmake
cmake_minimum_required(VERSION 2.8)
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_GREATER 2.8.3)
@@ -15,8 +15,15 @@ include(CMakeParseArguments.cmake)
# Detect Lion and force gcc
IF (APPLE)
EXECUTE_PROCESS(COMMAND sw_vers -productVersion OUTPUT_VARIABLE MACOSX_VERSION)
- IF (NOT ${MACOSX_VERSION} VERSION_LESS "10.8.0")
- message("Detected Mountain Lion (10.8) or later")
+ IF (NOT ${MACOSX_VERSION} VERSION_LESS "10.9.0")
+ message("Detected Maverick (10.9) or later")
+ set(CMAKE_C_COMPILER "clang")
+ set(CMAKE_CXX_COMPILER "clang++")
+ # Somehow, since we build dependencies for 10.7, we need to also build executables
+ # for 10.7. This used to not be necessary, but since 10.9 it apparently is..
+ SET(CMAKE_OSX_DEPLOYMENT_TARGET 10.7 CACHE STRING "Deployment target")
+ ELSEIF (NOT ${MACOSX_VERSION} VERSION_LESS "10.8.0")
+ message("Detected Mountain Lion (10.8)")
set(CMAKE_C_COMPILER "clang")
set(CMAKE_CXX_COMPILER "clang++")
ELSEIF (NOT ${MACOSX_VERSION} VERSION_LESS "10.7.0")
@@ -359,10 +366,10 @@ if (NOT $ENV{CGALDIR} STREQUAL "")
elseif (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "")
if (EXISTS "$ENV{OPENSCAD_LIBRARIES}/lib/CGAL")
set(CGAL_DIR "$ENV{OPENSCAD_LIBRARIES}/lib/CGAL")
- set(CMAKE_MODULE_PATH "${CGAL_DIR}")
+ set(CMAKE_MODULE_PATH "${CGAL_DIR}" ${CMAKE_MODULE_PATH})
elseif (EXISTS "$ENV{OPENSCAD_LIBRARIES}/include/CGAL")
set(CGAL_DIR "$ENV{OPENSCAD_LIBRARIES}")
- set(CMAKE_MODULE_PATH "${CGAL_DIR}")
+ set(CMAKE_MODULE_PATH "${CGAL_DIR}" ${CMAKE_MODULE_PATH})
endif()
endif()
message(STATUS "CGAL_DIR: " ${CGAL_DIR})
@@ -406,16 +413,9 @@ if (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "")
set(ENV{PKG_CONFIG_LIBDIR} "$ENV{OPENSCAD_LIBRARIES}/lib/pkgconfig")
endif()
-# Find libraries (system installed or dependency built) using pkg-config
-find_package(PkgConfig REQUIRED)
-
-#GLib-2
-pkg_search_module(GLIB2 REQUIRED glib-2.0>=2.2.0)
-#Can't use the CXXFlags directly as they are ;-separated
-string(REPLACE ";" " " GLIB2_CFLAGS "${GLIB2_CFLAGS}")
-message(STATUS "glib-2.0 found: ${GLIB2_VERSION}")
-
-add_definitions(${GLIB2_CFLAGS})
+find_package(GLIB2 2.2.0 REQUIRED)
+add_definitions(${GLIB2_DEFINITIONS})
+inclusion(GLIB2_DIR GLIB2_INCLUDE_DIRS)
# Imagemagick
@@ -588,7 +588,7 @@ set(OFFSCREEN_SOURCES
../src/OpenCSGRenderer.cc)
add_library(tests-core STATIC ${CORE_SOURCES})
-target_link_libraries(tests-core ${OPENGL_LIBRARIES} ${GLIB2_LIBRARIES} )
+target_link_libraries(tests-core)
set(TESTS-CORE-LIBRARIES ${OPENGL_LIBRARIES} ${GLIB2_LIBRARIES} ${Boost_LIBRARIES} )
add_library(tests-common STATIC ${COMMON_SOURCES})
@@ -609,7 +609,7 @@ set(TESTS-NOCGAL-LIBRARIES ${TESTS-CORE-LIBRARIES})
# modulecachetest
#
add_executable(modulecachetest modulecachetest.cc)
-target_link_libraries(modulecachetest tests-nocgal ${TESTS-NOCGAL-LIBRARIES} ${Boost_LIBRARIES})
+target_link_libraries(modulecachetest tests-nocgal ${TESTS-NOCGAL-LIBRARIES})
#
# csgtexttest
@@ -629,7 +629,7 @@ target_link_libraries(cgalcachetest tests-cgal ${TESTS-CGAL-LIBRARIES} ${GLEW_LI
#
add_executable(openscad_nogui ../src/openscad.cc)
set_target_properties(openscad_nogui PROPERTIES COMPILE_FLAGS "-fno-strict-aliasing -DEIGEN_DONT_ALIGN -DENABLE_CGAL -DENABLE_OPENCSG ${CGAL_CXX_FLAGS_INIT}")
-target_link_libraries(openscad_nogui tests-offscreen tests-cgal tests-nocgal ${TESTS-CORE-LIBRARIES} ${TESTS-CGAL-LIBRARIES} ${GLEW_LIBRARY} ${Boost_LIBRARIES} ${OPENCSG_LIBRARY} ${COCOA_LIBRARY} )
+target_link_libraries(openscad_nogui tests-offscreen tests-cgal tests-nocgal ${TESTS-CORE-LIBRARIES} ${TESTS-CGAL-LIBRARIES} ${GLEW_LIBRARY} ${OPENCSG_LIBRARY} ${COCOA_LIBRARY} )
#
# GUI binary tests
diff --git a/tests/FindGLIB2.cmake b/tests/FindGLIB2.cmake
new file mode 100644
index 0000000..b27b9a9
--- /dev/null
+++ b/tests/FindGLIB2.cmake
@@ -0,0 +1,27 @@
+find_package(PkgConfig REQUIRED)
+
+pkg_search_module(GLIB2 REQUIRED glib-2.0)
+#message("GLIB2_LIBRARIES ${GLIB2_LIBRARIES}")
+#message("GLIB2_LIBRARY_DIRS ${GLIB2_LIBRARY_DIRS}")
+#message("GLIB2_LDFLAGS ${GLIB2_LDFLAGS}")
+#message("GLIB2_LDFLAGS_OTHER ${GLIB2_LDFLAGS_OTHER}")
+message("GLIB2_INCLUDE_DIRS ${GLIB2_INCLUDE_DIRS}")
+#message("GLIB2_CFLAGS ${GLIB2_CFLAGS}")
+#message("GLIB2_CFLAGS_OTHER ${GLIB2_CFLAGS_OTHER}")
+#message("GLIB2_LIBDIR ${GLIB2_LIBDIR}")
+
+set(GLIB2_DEFINITIONS ${GLIB2_CFLAGS_OTHER})
+#message("GLIB2_DEFINITIONS ${GLIB2_DEFINITIONS}")
+
+set(GLIB2_LIBRARY_NAMES ${GLIB2_LIBRARIES})
+set(GLIB2_LIBRARIES "")
+foreach(GLIB2_LIB ${GLIB2_LIBRARY_NAMES})
+# message("lib: ${GLIB2_LIB}")
+ set(TMP TMP-NOTFOUND)
+ find_library(TMP NAMES ${GLIB2_LIB}
+ PATHS ${GLIB2_LIBRARY_DIRS}
+ NO_DEFAULT_PATH)
+# message("TMP: ${TMP}")
+ list(APPEND GLIB2_LIBRARIES "${TMP}")
+endforeach()
+message("GLIB2_LIBRARIES: ${GLIB2_LIBRARIES}")
contact: Jan Huwald // Impressum