diff --git a/CMakeLists.txt b/CMakeLists.txt index 05f26e8c..712c262c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,7 +156,7 @@ if (UNIX) CACHE STRING "" FORCE) endif() - set(CMAKE_CXX_FLAGS "--sysroot ${CMAKE_OSX_SYSROOT} ${CMAKE_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS "--sysroot ${CMAKE_OSX_SYSROOT} ${CMAKE_CXX_FLAGS} -DGTEST_USE_OWN_TR1_TUPLE=1") find_library(lib_ScreenSaver ScreenSaver) find_library(lib_IOKit IOKit) diff --git a/src/gui/gui.pro b/src/gui/gui.pro index bcc41d8f..82c6517b 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -71,7 +71,7 @@ HEADERS += src/MainWindow.h \ RESOURCES += res/Synergy.qrc RC_FILE = res/win/Synergy.rc macx { - QMAKE_INFO_PLIST = res/mac/Synergy.plist + QMAKE_INFO_PLIST = res/mac/Info.plist QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4 TARGET = Synergy QSYNERGY_ICON.files = res/mac/Synergy.icns diff --git a/src/gui/res/mac/Synergy.plist b/src/gui/res/mac/Info.plist similarity index 87% rename from src/gui/res/mac/Synergy.plist rename to src/gui/res/mac/Info.plist index 81ed05d6..f2180455 100644 --- a/src/gui/res/mac/Synergy.plist +++ b/src/gui/res/mac/Info.plist @@ -6,11 +6,11 @@ Synergy.icns CFBundlePackageType APPL - CFBundleGetInfoString - 0.9.0 CFBundleSignature ???? CFBundleExecutable Synergy + CFBundleIdentifier + synergy diff --git a/src/gui/src/main.cpp b/src/gui/src/main.cpp index 60cd7f6c..0cab4a9a 100644 --- a/src/gui/src/main.cpp +++ b/src/gui/src/main.cpp @@ -28,6 +28,10 @@ #include #include +#if defined(Q_OS_MAC) +#include +#endif + class QThreadImpl : public QThread { public: @@ -39,6 +43,10 @@ public: int waitForTray(); +#if defined(Q_OS_MAC) +bool checkMacAssistiveDevices(); +#endif + int main(int argc, char* argv[]) { QCoreApplication::setOrganizationName("Synergy"); @@ -47,8 +55,17 @@ int main(int argc, char* argv[]) QSynergyApplication app(argc, argv); +#if defined(Q_OS_MAC) + if (!checkMacAssistiveDevices()) + { + return 1; + } +#endif + if (!waitForTray()) + { return -1; + } #ifndef Q_OS_WIN QApplication::setQuitOnLastWindowClosed(false); @@ -98,3 +115,33 @@ int waitForTray() return true; } +#if defined(Q_OS_MAC) +bool checkMacAssistiveDevices() +{ +#if defined(MAC_OS_X_VERSION_10_9) // mavericks + + // new in mavericks, applications are trusted individually + // with use of the accessibility api. this call will show a + // prompt which can show the security/privacy/accessibility + // tab, with a list of allowed applications. synergy should + // show up there automatically, but will be unchecked. + + const void* keys[] = { kAXTrustedCheckOptionPrompt }; + const void* values[] = { kCFBooleanTrue }; + + CFDictionaryRef options = CFDictionaryCreate(NULL, keys, values, 1, NULL, NULL); + bool result = AXIsProcessTrustedWithOptions(options); + CFRelease(options); + + return result; + +#else + + // now deprecated in mavericks. + bool result = AXAPIEnabled(); + QMessageBox::information(NULL, "Synergy", "Please enable access to assistive devices (System Preferences), then re-open Synergy."); + return result; + +#endif +} +#endif diff --git a/src/lib/platform/COSXScreen.cpp b/src/lib/platform/COSXScreen.cpp index 11b376a4..6fddce96 100644 --- a/src/lib/platform/COSXScreen.cpp +++ b/src/lib/platform/COSXScreen.cpp @@ -108,9 +108,21 @@ COSXScreen::COSXScreen(IEventQueue* events, bool isPrimary, bool autoShowHideCur m_screensaver = new COSXScreenSaver(m_events, getEventTarget()); m_keyState = new COSXKeyState(m_events); - // TODO: http://stackoverflow.com/questions/2950124/enable-access-for-assistive-device-programmatically - if (m_isPrimary && !AXAPIEnabled()) - throw XArch("system setting not enabled: \"Enable access for assistive devices\""); + // only needed when running as a server. + if (m_isPrimary) { + +#if defined(MAC_OS_X_VERSION_10_9) + // we can't pass options to show the dialog, this must be done by the gui. + //if (!AXIsProcessTrusted()) { + // throw XArch("assistive devices does not trust this process, allow it in system settings."); + //} +#else + // now deprecated in mavericks. + if (!AXAPIEnabled()) { + throw XArch("assistive devices is not enabled, enable it in system settings."); + } +#endif + } // install display manager notification handler #if defined(MAC_OS_X_VERSION_10_5) diff --git a/src/lib/server/CConfig.cpp b/src/lib/server/CConfig.cpp index 2b27425d..06af6ac0 100644 --- a/src/lib/server/CConfig.cpp +++ b/src/lib/server/CConfig.cpp @@ -615,7 +615,7 @@ void CConfig::read(CConfigReadContext& context) { CConfig tmp(m_events); - while (context) { + while (context.getStream()) { tmp.readSection(context); } *this = tmp; @@ -1924,11 +1924,6 @@ CConfigReadContext::getLineNumber() const return m_line; } -CConfigReadContext::operator void*() const -{ - return m_stream; -} - bool CConfigReadContext::operator!() const { diff --git a/src/lib/server/CConfig.h b/src/lib/server/CConfig.h index 5f6685ad..3abdb3f9 100644 --- a/src/lib/server/CConfig.h +++ b/src/lib/server/CConfig.h @@ -491,7 +491,6 @@ public: bool readLine(CString&); UInt32 getLineNumber() const; - operator void*() const; bool operator!() const; OptionValue parseBoolean(const CString&) const; @@ -513,6 +512,7 @@ public: IPlatformScreen::CButtonInfo* parseMouse(const CString& mouse) const; KeyModifierMask parseModifier(const CString& modifiers) const; + std::istream& getStream() const { return m_stream; }; private: // not implemented