Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 45 additions & 25 deletions bottlecaps-qt.pro
Original file line number Diff line number Diff line change
Expand Up @@ -318,31 +318,61 @@ OTHER_FILES += \
# platform specific defaults, if not overridden on command line
isEmpty(BOOST_LIB_SUFFIX) {
macx:BOOST_LIB_SUFFIX = -mt
windows:BOOST_LIB_SUFFIX = -mgw46-mt-sd-1_54
windows:BOOST_LIB_SUFFIX = -mgw44-mt-s-1_50
}

isEmpty(BOOST_THREAD_LIB_SUFFIX) {
BOOST_THREAD_LIB_SUFFIX = $$BOOST_LIB_SUFFIX
}

isEmpty(BDB_LIB_PATH) {
macx:BDB_LIB_PATH = /opt/local/lib/db48
}
macx: {

isEmpty(BDB_LIB_SUFFIX) {
macx:BDB_LIB_SUFFIX = -4.8
}
isEmpty(DEPSDIR) {

isEmpty(BDB_INCLUDE_PATH) {
macx:BDB_INCLUDE_PATH = /opt/local/include/db48
}
check_dir = /usr/local/Cellar
exists($$check_dir) {
DEPSDIR = /usr/local
}

isEmpty(BOOST_LIB_PATH) {
macx:BOOST_LIB_PATH = /opt/local/lib
}
!exists($$check_dir) {
DEPSDIR = /opt/local
}
}

isEmpty(BOOST_LIB_PATH) {
BOOST_LIB_PATH = $$DEPSDIR/lib
}

isEmpty(BOOST_INCLUDE_PATH) {
macx:BOOST_INCLUDE_PATH = /opt/local/include
isEmpty(BOOST_INCLUDE_PATH) {
BOOST_INCLUDE_PATH = $$DEPSDIR/include
}

isEmpty(BDB_LIB_PATH) {
BDB_LIB_PATH = $$DEPSDIR/lib
}

isEmpty(BDB_INCLUDE_PATH) {
BDB_INCLUDE_PATH = $$DEPSDIR/include
}

HEADERS += src/qt/macdockiconhandler.h src/qt/macnotificationhandler.h
OBJECTIVE_SOURCES += src/qt/macdockiconhandler.mm src/qt/macnotificationhandler.mm
LIBS += -framework Foundation -framework ApplicationServices -framework AppKit -framework CoreServices \
$$BDB_LIB_PATH/libdb_cxx.a \
$$BOOST_LIB_PATH/libboost_system-mt.a \
$$BOOST_LIB_PATH/libboost_filesystem-mt.a \
$$BOOST_LIB_PATH/libboost_program_options-mt.a \
$$BOOST_LIB_PATH/libboost_thread-mt.a \
$$BOOST_LIB_PATH/libboost_chrono-mt.a
DEFINES += MAC_OSX MSG_NOSIGNAL=0
# osx 10.9 has changed the stdlib default to libc++. To prevent some link error, you may need to use libstdc++
QMAKE_CXXFLAGS += -stdlib=libstdc++

ICON = src/qt/res/icons/BottleCaps.icns
TARGET = "BottleCaps-Qt"

QMAKE_CFLAGS_THREAD += -pthread
QMAKE_CXXFLAGS_THREAD += -pthread
}

windows:DEFINES += WIN32
Expand All @@ -364,16 +394,6 @@ windows:!contains(MINGW_THREAD_BUGFIX, 0) {
LIBS += -lrt
}

macx:HEADERS += src/qt/macdockiconhandler.h
macx:OBJECTIVE_SOURCES += src/qt/macdockiconhandler.mm
macx:LIBS += -framework Foundation -framework ApplicationServices -framework AppKit
macx:DEFINES += MAC_OSX MSG_NOSIGNAL=0
macx:ICON = src/qt/res/icons/bitcoin.icns
macx:TARGET = "BottleCaps-Qt"
macx:QMAKE_CFLAGS_THREAD += -pthread
macx:QMAKE_LFLAGS_THREAD += -pthread
macx:QMAKE_CXXFLAGS_THREAD += -pthread

# Set libraries and includes at end, to use platform-defined defaults if not overridden
INCLUDEPATH += $$BOOST_INCLUDE_PATH $$BDB_INCLUDE_PATH $$OPENSSL_INCLUDE_PATH $$QRENCODE_INCLUDE_PATH
LIBS += $$join(BOOST_LIB_PATH,,-L,) $$join(BDB_LIB_PATH,,-L,) $$join(OPENSSL_LIB_PATH,,-L,) $$join(QRENCODE_LIB_PATH,,-L,)
Expand Down
30 changes: 30 additions & 0 deletions src/qt/macnotificationhandler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) 2011-2013 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#ifndef MACNOTIFICATIONHANDLER_H
#define MACNOTIFICATIONHANDLER_H

#include <QObject>

/** Macintosh-specific notification handler (supports UserNotificationCenter and Growl).
*/
class MacNotificationHandler : public QObject
{
Q_OBJECT

public:
/** shows a 10.8+ UserNotification in the UserNotificationCenter
*/
void showNotification(const QString &title, const QString &text);

/** executes AppleScript */
void sendAppleScript(const QString &script);

/** check if OS can handle UserNotifications */
bool hasUserNotificationCenterSupport(void);
static MacNotificationHandler *instance();
};


#endif // MACNOTIFICATIONHANDLER_H
65 changes: 65 additions & 0 deletions src/qt/macnotificationhandler.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#include "macnotificationhandler.h"

#undef slots
#include <Cocoa/Cocoa.h>

void MacNotificationHandler::showNotification(const QString &title, const QString &text)
{
// check if users OS has support for NSUserNotification
if(this->hasUserNotificationCenterSupport()) {
// okay, seems like 10.8+
QByteArray utf8 = title.toUtf8();
char* cString = (char *)utf8.constData();
NSString *titleMac = [[NSString alloc] initWithUTF8String:cString];

utf8 = text.toUtf8();
cString = (char *)utf8.constData();
NSString *textMac = [[NSString alloc] initWithUTF8String:cString];

// do everything weak linked (because we will keep <10.8 compatibility)
id userNotification = [[NSClassFromString(@"NSUserNotification") alloc] init];
[userNotification performSelector:@selector(setTitle:) withObject:titleMac];
[userNotification performSelector:@selector(setInformativeText:) withObject:textMac];

id notificationCenterInstance = [NSClassFromString(@"NSUserNotificationCenter") performSelector:@selector(defaultUserNotificationCenter)];
[notificationCenterInstance performSelector:@selector(deliverNotification:) withObject:userNotification];

[titleMac release];
[textMac release];
[userNotification release];
}
}

// sendAppleScript just take a QString and executes it as apple script
void MacNotificationHandler::sendAppleScript(const QString &script)
{
QByteArray utf8 = script.toUtf8();
char* cString = (char *)utf8.constData();
NSString *scriptApple = [[NSString alloc] initWithUTF8String:cString];

NSAppleScript *as = [[NSAppleScript alloc] initWithSource:scriptApple];
NSDictionary *err = nil;
[as executeAndReturnError:&err];
[as release];
[scriptApple release];
}

bool MacNotificationHandler::hasUserNotificationCenterSupport(void)
{
Class possibleClass = NSClassFromString(@"NSUserNotificationCenter");

// check if users OS has support for NSUserNotification
if(possibleClass!=nil) {
return true;
}
return false;
}


MacNotificationHandler *MacNotificationHandler::instance()
{
static MacNotificationHandler *s_instance = NULL;
if (!s_instance)
s_instance = new MacNotificationHandler();
return s_instance;
}
45 changes: 30 additions & 15 deletions src/qt/notificator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
#include <QImageWriter>

#ifdef USE_DBUS
#include <QtDBus/QtDBus>
#include <QtDBus>
#include <stdint.h>
#endif

#ifdef Q_OS_MAC
#include <ApplicationServices/ApplicationServices.h>
extern bool qt_mac_execute_apple_script(const QString &script, AEDesc *ret);
#include "macnotificationhandler.h"
#endif

// https://wiki.ubuntu.com/NotificationDevelopmentGuidelines recommends at least 128
Expand Down Expand Up @@ -47,19 +47,25 @@ Notificator::Notificator(const QString &programName, QSystemTrayIcon *trayicon,
}
#endif
#ifdef Q_OS_MAC
// Check if Growl is installed (based on Qt's tray icon implementation)
CFURLRef cfurl;
OSStatus status = LSGetApplicationForInfo(kLSUnknownType, kLSUnknownCreator, CFSTR("growlTicket"), kLSRolesAll, 0, &cfurl);
if (status != kLSApplicationNotFoundErr) {
CFBundleRef bundle = CFBundleCreate(0, cfurl);
if (CFStringCompare(CFBundleGetIdentifier(bundle), CFSTR("com.Growl.GrowlHelperApp"), kCFCompareCaseInsensitive | kCFCompareBackwards) == kCFCompareEqualTo) {
if (CFStringHasSuffix(CFURLGetString(cfurl), CFSTR("/Growl.app/")))
mode = Growl13;
else
mode = Growl12;
// check if users OS has support for NSUserNotification
if( MacNotificationHandler::instance()->hasUserNotificationCenterSupport()) {
mode = UserNotificationCenter;
}
else {
// Check if Growl is installed (based on Qt's tray icon implementation)
CFURLRef cfurl;
OSStatus status = LSGetApplicationForInfo(kLSUnknownType, kLSUnknownCreator, CFSTR("growlTicket"), kLSRolesAll, 0, &cfurl);
if (status != kLSApplicationNotFoundErr) {
CFBundleRef bundle = CFBundleCreate(0, cfurl);
if (CFStringCompare(CFBundleGetIdentifier(bundle), CFSTR("com.Growl.GrowlHelperApp"), kCFCompareCaseInsensitive | kCFCompareBackwards) == kCFCompareEqualTo) {
if (CFStringHasSuffix(CFURLGetString(cfurl), CFSTR("/Growl.app/")))
mode = Growl13;
else
mode = Growl12;
}
CFRelease(cfurl);
CFRelease(bundle);
}
CFRelease(cfurl);
CFRelease(bundle);
}
#endif
}
Expand Down Expand Up @@ -269,8 +275,14 @@ void Notificator::notifyGrowl(Class cls, const QString &title, const QString &te
quotedTitle.replace("\\", "\\\\").replace("\"", "\\");
quotedText.replace("\\", "\\\\").replace("\"", "\\");
QString growlApp(this->mode == Notificator::Growl13 ? "Growl" : "GrowlHelperApp");
qt_mac_execute_apple_script(script.arg(notificationApp, quotedTitle, quotedText, notificationIcon, growlApp), 0);
MacNotificationHandler::instance()->sendAppleScript(script.arg(notificationApp, quotedTitle, quotedText, notificationIcon, growlApp));
}

void Notificator::notifyMacUserNotificationCenter(Class cls, const QString &title, const QString &text, const QIcon &icon) {
// icon is not supported by the user notification center yet. OSX will use the app icon.
MacNotificationHandler::instance()->showNotification(title, text);
}

#endif

void Notificator::notify(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout)
Expand All @@ -286,6 +298,9 @@ void Notificator::notify(Class cls, const QString &title, const QString &text, c
notifySystray(cls, title, text, icon, millisTimeout);
break;
#ifdef Q_OS_MAC
case UserNotificationCenter:
notifyMacUserNotificationCenter(cls, title, text, icon);
break;
case Growl12:
case Growl13:
notifyGrowl(cls, title, text, icon);
Expand Down
20 changes: 11 additions & 9 deletions src/qt/notificator.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ QT_END_NAMESPACE
class Notificator: public QObject
{
Q_OBJECT

public:
/** Create a new notificator.
@note Ownership of trayIcon is not transferred to this object.
Expand All @@ -25,13 +26,12 @@ class Notificator: public QObject
// Message class
enum Class
{
Information, /**< Informational message */
Warning, /**< Notify user of potential problem */
Critical /**< An error occurred */
Information, /**< Informational message */
Warning, /**< Notify user of potential problem */
Critical /**< An error occurred */
};

public slots:

/** Show notification message.
@param[in] cls general message class
@param[in] title title shown with message
Expand All @@ -46,11 +46,12 @@ public slots:
private:
QWidget *parent;
enum Mode {
None, /**< Ignore informational notifications, and show a modal pop-up dialog for Critical notifications. */
Freedesktop, /**< Use DBus org.freedesktop.Notifications */
QSystemTray, /**< Use QSystemTray::showMessage */
Growl12, /**< Use the Growl 1.2 notification system (Mac only) */
Growl13 /**< Use the Growl 1.3 notification system (Mac only) */
None, /**< Ignore informational notifications, and show a modal pop-up dialog for Critical notifications. */
Freedesktop, /**< Use DBus org.freedesktop.Notifications */
QSystemTray, /**< Use QSystemTray::showMessage */
Growl12, /**< Use the Growl 1.2 notification system (Mac only) */
Growl13, /**< Use the Growl 1.3 notification system (Mac only) */
UserNotificationCenter /**< Use the 10.8+ User Notification Center (Mac only) */
};
QString programName;
Mode mode;
Expand All @@ -63,6 +64,7 @@ public slots:
void notifySystray(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout);
#ifdef Q_OS_MAC
void notifyGrowl(Class cls, const QString &title, const QString &text, const QIcon &icon);
void notifyMacUserNotificationCenter(Class cls, const QString &title, const QString &text, const QIcon &icon);
#endif
};

Expand Down
12 changes: 6 additions & 6 deletions src/scrypt-x86_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@


.text
.align 32
.align 16
gen_salsa8_core:
# 0: %rdx, %rdi, %rcx, %rsi
movq 8(%rsp), %rdi
Expand Down Expand Up @@ -274,7 +274,7 @@ gen_salsa8_core:


.text
.align 32
.align 16
.globl scrypt_core
.globl _scrypt_core
scrypt_core:
Expand Down Expand Up @@ -525,7 +525,7 @@ gen_scrypt_core_loop2:
xmm_salsa8_core_doubleround(); \


.align 32
.align 16
xmm_scrypt_core:
# shuffle 1st block into %xmm8-%xmm11
movl 60(%rdi), %edx
Expand Down Expand Up @@ -837,7 +837,7 @@ xmm_scrypt_core_loop2:


.text
.align 32
.align 16
.globl scrypt_best_throughput
.globl _scrypt_best_throughput
scrypt_best_throughput:
Expand Down Expand Up @@ -999,7 +999,7 @@ scrypt_best_throughput_exit:


.text
.align 32
.align 16
.globl scrypt_core_2way
.globl _scrypt_core_2way
scrypt_core_2way:
Expand Down Expand Up @@ -1461,7 +1461,7 @@ scrypt_core_2way_loop2:


.text
.align 32
.align 16
.globl scrypt_core_3way
.globl _scrypt_core_3way
scrypt_core_3way:
Expand Down