summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@qt.io>2017-01-05 14:14:41 -0800
committerJake Petroules <jake.petroules@qt.io>2017-01-24 19:40:40 +0000
commitc1cece8e546a138609c974be94588ba4e72c6fb1 (patch)
treea355ec5cc99bd1b8ab48ff490afb66fc63d27d7b /src/plugins
parentffc9d27d7eb5c6779c6bf3963bac2dafb2a828cf (diff)
Fix deprecated API usage
Change-Id: I62448507f80daf6be72994ee99f0fb1aa107eb78 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/bearer/corewlan/qcorewlanengine.mm40
-rw-r--r--src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm14
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm14
-rw-r--r--src/plugins/platforms/cocoa/qcocoanativeinterface.mm7
5 files changed, 42 insertions, 37 deletions
diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm
index 7cf9365513..341d3bccf2 100644
--- a/src/plugins/bearer/corewlan/qcorewlanengine.mm
+++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm
@@ -61,14 +61,14 @@ extern "C" { // Otherwise it won't find CWKeychain* symbols at link time
#include <net/if.h>
#include <ifaddrs.h>
-@interface QT_MANGLE_NAMESPACE(QNSListener) : NSObject
+@interface QT_MANGLE_NAMESPACE(QNSListener) : NSObject <CWEventDelegate>
{
NSNotificationCenter *notificationCenter;
- CWInterface *currentInterface;
+ CWWiFiClient *client;
QCoreWlanEngine *engine;
NSLock *locker;
}
-- (void)notificationHandler:(NSNotification *)notification;
+- (void)powerStateDidChangeForWiFiInterfaceWithName:(NSString *)interfaceName;
- (void)remove;
- (void)setEngine:(QCoreWlanEngine *)coreEngine;
- (QCoreWlanEngine *)engine;
@@ -85,8 +85,9 @@ extern "C" { // Otherwise it won't find CWKeychain* symbols at link time
[locker lock];
QMacAutoReleasePool pool;
notificationCenter = [NSNotificationCenter defaultCenter];
- currentInterface = [CWInterface interface];
- [notificationCenter addObserver:self selector:@selector(notificationHandler:) name:CWPowerDidChangeNotification object:nil];
+ client = [CWWiFiClient sharedWiFiClient];
+ client.delegate = self;
+ [client startMonitoringEventWithType:CWEventTypePowerDidChange error:nil];
[locker unlock];
return self;
}
@@ -95,6 +96,7 @@ static QT_MANGLE_NAMESPACE(QNSListener) *listener = 0;
-(void)dealloc
{
+ client.delegate = nil;
listener = nil;
[super dealloc];
}
@@ -115,13 +117,13 @@ static QT_MANGLE_NAMESPACE(QNSListener) *listener = 0;
-(void)remove
{
[locker lock];
- [notificationCenter removeObserver:self];
+ [client stopMonitoringAllEventsAndReturnError:nil];
[locker unlock];
}
-- (void)notificationHandler:(NSNotification *)notification
+- (void)powerStateDidChangeForWiFiInterfaceWithName:(NSString *)interfaceName
{
- Q_UNUSED(notification);
+ Q_UNUSED(interfaceName);
engine->requestUpdate();
}
@end
@@ -162,7 +164,8 @@ void QScanThread::run()
QMacAutoReleasePool pool;
QStringList found;
mutex.lock();
- CWInterface *currentInterface = [CWInterface interfaceWithName:interfaceName.toNSString()];
+ CWInterface *currentInterface = [[CWWiFiClient sharedWiFiClient]
+ interfaceWithName:interfaceName.toNSString()];
mutex.unlock();
const bool currentInterfaceServiceActive = currentInterface.serviceActive;
@@ -284,10 +287,10 @@ void QScanThread::getUserConfigurations()
QMacAutoReleasePool pool;
userProfiles.clear();
- NSSet *wifiInterfaces = [CWInterface interfaceNames];
+ NSArray<NSString *> *wifiInterfaces = [CWWiFiClient interfaceNames];
for (NSString *ifName in wifiInterfaces) {
- CWInterface *wifiInterface = [CWInterface interfaceWithName:ifName];
+ CWInterface *wifiInterface = [[CWWiFiClient sharedWiFiClient] interfaceWithName:ifName];
NSString *nsInterfaceName = wifiInterface.ssid;
// add user configured system networks
@@ -442,7 +445,7 @@ void QCoreWlanEngine::initialize()
QMutexLocker locker(&mutex);
QMacAutoReleasePool pool;
- if ([[CWInterface interfaceNames] count] > 0 && !listener) {
+ if ([[CWWiFiClient interfaceNames] count] > 0 && !listener) {
listener = [[QT_MANGLE_NAMESPACE(QNSListener) alloc] init];
listener.engine = this;
hasWifi = true;
@@ -476,7 +479,7 @@ void QCoreWlanEngine::connectToId(const QString &id)
QString interfaceString = getInterfaceFromId(id);
CWInterface *wifiInterface =
- [CWInterface interfaceWithName:interfaceString.toNSString()];
+ [[CWWiFiClient sharedWiFiClient] interfaceWithName:interfaceString.toNSString()];
if (wifiInterface.powerOn) {
NSError *err = nil;
@@ -559,7 +562,7 @@ void QCoreWlanEngine::disconnectFromId(const QString &id)
QMacAutoReleasePool pool;
CWInterface *wifiInterface =
- [CWInterface interfaceWithName:interfaceString.toNSString()];
+ [[CWWiFiClient sharedWiFiClient] interfaceWithName:interfaceString.toNSString()];
disconnectedInterfaceString = interfaceString;
[wifiInterface disassociate];
@@ -573,8 +576,8 @@ void QCoreWlanEngine::checkDisconnect()
if (!disconnectedInterfaceString.isEmpty()) {
QMacAutoReleasePool pool;
- CWInterface *wifiInterface =
- [CWInterface interfaceWithName:disconnectedInterfaceString.toNSString()];
+ CWInterface *wifiInterface = [[CWWiFiClient sharedWiFiClient]
+ interfaceWithName:disconnectedInterfaceString.toNSString()];
const QString networkSsid = QString::fromNSString([wifiInterface ssid]);
if (!networkSsid.isEmpty()) {
@@ -599,7 +602,7 @@ void QCoreWlanEngine::doRequestUpdate()
QMacAutoReleasePool pool;
- NSSet *wifiInterfaces = [CWInterface interfaceNames];
+ NSArray<NSString *> *wifiInterfaces = [CWWiFiClient interfaceNames];
for (NSString *ifName in wifiInterfaces) {
scanThread->interfaceName = QString::fromNSString(ifName);
scanThread->start();
@@ -615,7 +618,8 @@ bool QCoreWlanEngine::isWifiReady(const QString &wifiDeviceName)
bool haswifi = false;
if(hasWifi) {
QMacAutoReleasePool pool;
- CWInterface *defaultInterface = [CWInterface interfaceWithName:wifiDeviceName.toNSString()];
+ CWInterface *defaultInterface = [[CWWiFiClient sharedWiFiClient]
+ interfaceWithName:wifiDeviceName.toNSString()];
if (defaultInterface.powerOn) {
haswifi = true;
}
diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
index e53c085e41..a8974c4de5 100644
--- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
@@ -80,7 +80,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
mHelper = 0;
mStolenContentView = 0;
mPanelButtons = nil;
- mResultCode = NSCancelButton;
+ mResultCode = NSModalResponseCancel;
mDialogIsExecuting = false;
mResultSet = false;
mClosingDueToKnownButton = false;
@@ -168,7 +168,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
mClosingDueToKnownButton = true;
[mColorPanel close];
[self updateQtColor];
- [self finishOffWithCode:NSOKButton];
+ [self finishOffWithCode:NSModalResponseOK];
}
- (void)onCancelClicked
@@ -177,7 +177,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
mClosingDueToKnownButton = true;
[mColorPanel close];
mQtColor = QColor();
- [self finishOffWithCode:NSCancelButton];
+ [self finishOffWithCode:NSModalResponseCancel];
}
}
@@ -238,12 +238,12 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
[NSApp runModalForWindow:mColorPanel];
mDialogIsExecuting = false;
- return (mResultCode == NSOKButton);
+ return (mResultCode == NSModalResponseOK);
}
- (QPlatformDialogHelper::DialogCode)dialogResultCode
{
- return (mResultCode == NSOKButton) ? QPlatformDialogHelper::Accepted : QPlatformDialogHelper::Rejected;
+ return (mResultCode == NSModalResponseOK) ? QPlatformDialogHelper::Accepted : QPlatformDialogHelper::Rejected;
}
- (BOOL)windowShouldClose:(id)window
@@ -252,7 +252,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
if (!mPanelButtons)
[self updateQtColor];
if (mDialogIsExecuting) {
- [self finishOffWithCode:NSCancelButton];
+ [self finishOffWithCode:NSModalResponseCancel];
} else {
mResultSet = true;
if (mHelper)
@@ -278,7 +278,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
// This check will prevent any such recursion.
if (!mResultSet) {
mResultSet = true;
- if (mResultCode == NSCancelButton) {
+ if (mResultCode == NSModalResponseCancel) {
emit mHelper->reject();
} else {
emit mHelper->accept();
diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
index 72c7856c2d..d2f985ec87 100644
--- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
+++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
@@ -401,7 +401,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
// [NSApp run], which is the normal code path for cocoa applications.
if (NSModalSession session = d->currentModalSession()) {
QBoolBlocker execGuard(d->currentExecIsNSAppRun, false);
- while ([NSApp runModalSession:session] == NSRunContinuesResponse && !d->interrupt)
+ while ([NSApp runModalSession:session] == NSModalResponseContinue && !d->interrupt)
qt_mac_waitForMoreEvents(NSModalPanelRunLoopMode);
if (!d->interrupt && session == d->currentModalSessionCached) {
@@ -435,7 +435,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
if (flags & QEventLoop::WaitForMoreEvents)
qt_mac_waitForMoreEvents(NSModalPanelRunLoopMode);
NSInteger status = [NSApp runModalSession:session];
- if (status != NSRunContinuesResponse && session == d->currentModalSessionCached) {
+ if (status != NSModalResponseContinue && session == d->currentModalSessionCached) {
// INVARIANT: Someone called [NSApp stopModal:] from outside the event
// dispatcher (e.g to stop a native dialog). But that call wrongly stopped
// 'session' as well. As a result, we need to restart all internal sessions:
diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
index 33dd4260a5..e4b796dcde 100644
--- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
@@ -106,7 +106,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
mHelper = 0;
mStolenContentView = 0;
mPanelButtons = 0;
- mResultCode = NSCancelButton;
+ mResultCode = NSModalResponseCancel;
mDialogIsExecuting = false;
mResultSet = false;
@@ -171,7 +171,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
- (void)onOkClicked
{
[mFontPanel close];
- [self finishOffWithCode:NSOKButton];
+ [self finishOffWithCode:NSModalResponseOK];
}
- (void)onCancelClicked
@@ -179,7 +179,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
if (mPanelButtons) {
[mFontPanel close];
mQtFont = QFont();
- [self finishOffWithCode:NSCancelButton];
+ [self finishOffWithCode:NSModalResponseCancel];
}
}
@@ -224,12 +224,12 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
[NSApp runModalForWindow:mFontPanel];
mDialogIsExecuting = false;
- return (mResultCode == NSOKButton);
+ return (mResultCode == NSModalResponseOK);
}
- (QPlatformDialogHelper::DialogCode)dialogResultCode
{
- return (mResultCode == NSOKButton) ? QPlatformDialogHelper::Accepted : QPlatformDialogHelper::Rejected;
+ return (mResultCode == NSModalResponseOK) ? QPlatformDialogHelper::Accepted : QPlatformDialogHelper::Rejected;
}
- (BOOL)windowShouldClose:(id)window
@@ -238,7 +238,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
if (!mPanelButtons)
[self updateQtFont];
if (mDialogIsExecuting) {
- [self finishOffWithCode:NSCancelButton];
+ [self finishOffWithCode:NSModalResponseCancel];
} else {
mResultSet = true;
if (mHelper)
@@ -264,7 +264,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
// This check will prevent any such recursion.
if (!mResultSet) {
mResultSet = true;
- if (mResultCode == NSCancelButton) {
+ if (mResultCode == NSModalResponseCancel) {
emit mHelper->reject();
} else {
emit mHelper->accept();
diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
index 972230349b..26ab07ffaf 100644
--- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
+++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
@@ -172,11 +172,12 @@ void *QCocoaNativeInterface::NSPrintInfoForPrintEngine(QPrintEngine *printEngine
QPixmap QCocoaNativeInterface::defaultBackgroundPixmapForQWizard()
{
- QCFType<CFURLRef> url;
const int ExpectedImageWidth = 242;
const int ExpectedImageHeight = 414;
- if (LSFindApplicationForInfo(kLSUnknownCreator, CFSTR("com.apple.KeyboardSetupAssistant"),
- 0, 0, &url) == noErr) {
+ QCFType<CFArrayRef> urls = LSCopyApplicationURLsForBundleIdentifier(
+ CFSTR("com.apple.KeyboardSetupAssistant"), nullptr);
+ if (urls && CFArrayGetCount(urls) > 0) {
+ CFURLRef url = (CFURLRef)CFArrayGetValueAtIndex(urls, 0);
QCFType<CFBundleRef> bundle = CFBundleCreate(kCFAllocatorDefault, url);
if (bundle) {
url = CFBundleCopyResourceURL(bundle, CFSTR("Background"), CFSTR("png"), 0);