diff --git a/CMakeLists.txt b/CMakeLists.txt index 2fb1a617b..cc59cbc22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,7 +107,6 @@ if(LASTFM_INCLUDE_DIRS AND LASTFM1_INCLUDE_DIRS) endif() if (APPLE) - find_library(GROWL Growl) find_library(SPARKLE Sparkle) find_library(SPOTIFY libspotify) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a9bfeec85..93fa03387 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -853,7 +853,6 @@ optional_source(HAVE_SPOTIFY_DOWNLOADER # Platform specific - OS X optional_source(APPLE INCLUDE_DIRECTORIES - ${GROWL}/Headers ${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/google-breakpad/client/mac/build/Release/Breakpad.framework SOURCES core/macfslistener.mm @@ -1290,7 +1289,6 @@ endif() if (APPLE) target_link_libraries(clementine_lib - ${GROWL} /System/Library/Frameworks/AppKit.framework /System/Library/Frameworks/Carbon.framework /System/Library/Frameworks/CoreAudio.framework @@ -1395,9 +1393,6 @@ if (APPLE) DESTINATION "${CMAKE_BINARY_DIR}/clementine.app/Contents/Frameworks/Sparkle.framework") endif (HAVE_SPARKLE) - install(DIRECTORY "${GROWL}/Versions/Current/Resources" - DESTINATION "${CMAKE_BINARY_DIR}/clementine.app/Contents/Frameworks/Growl.framework") - install(FILES "${QT_QTCORE_LIBRARY_RELEASE}/Contents/Info.plist" DESTINATION "${CMAKE_BINARY_DIR}/clementine.app/Contents/Frameworks/QtCore.framework/Contents") install(FILES "${QT_QTGUI_LIBRARY_RELEASE}/Contents/Info.plist" diff --git a/src/widgets/osd.h b/src/widgets/osd.h index 8103fd5c5..f4f36962d 100644 --- a/src/widgets/osd.h +++ b/src/widgets/osd.h @@ -127,11 +127,6 @@ class OSD : public QObject { QString last_image_uri_; QImage last_image_; -#ifdef Q_OS_DARWIN - class GrowlNotificationWrapper; - GrowlNotificationWrapper* wrapper_; -#endif // Q_OS_DARWIN - #ifdef HAVE_DBUS std::unique_ptr interface_; uint notification_id_; diff --git a/src/widgets/osd_mac.mm b/src/widgets/osd_mac.mm index 0147aca5d..d24b902c8 100644 --- a/src/widgets/osd_mac.mm +++ b/src/widgets/osd_mac.mm @@ -22,117 +22,8 @@ #include #include -#import - -#include "core/scoped_nsautorelease_pool.h" #include "core/scoped_nsobject.h" -@interface GrowlInterface : NSObject { -} -- (void)SendGrowlAlert:(NSString*)message - title:(NSString*)title - image:(NSData*)image; -- (void)ClickCallback; // Called when user clicks on notification. -@end - -@implementation GrowlInterface - -- (id)init { - if ((self = [super init])) { - [GrowlApplicationBridge setGrowlDelegate:self]; - } - return self; -} - -- (void)dealloc { - [super dealloc]; -} - -- (NSDictionary*)registrationDictionaryForGrowl { - NSArray* array = [NSArray - arrayWithObjects:@"next_track", nil]; // Valid notification names. - NSDictionary* dict = [NSDictionary - dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:1], @"TicketVersion", - array, @"AllNotifications", array, - @"DefaultNotifications", - @"com.davidsansome.clementine", - @"ApplicationId", nil]; - return dict; -} - -- (void)growlNotificationWasClicked:(id)clickContext { - if (clickContext) { - [self ClickCallback]; - } - return; -} - -- (void)SendGrowlAlert:(NSString*)message - title:(NSString*)title - image:(NSData*)image { - [GrowlApplicationBridge - notifyWithTitle:title - description:message - notificationName:@"next_track" - iconData:image - priority:0 - isSticky:NO - clickContext:@"click_callback"]; // String sent to our callback. -} - -- (void)ClickCallback { - qDebug() << "Growl notification clicked!"; - return; -} - -@end - -class OSD::GrowlNotificationWrapper { - public: - GrowlNotificationWrapper() { - growl_interface_ = [[GrowlInterface alloc] init]; - } - - ~GrowlNotificationWrapper() { [growl_interface_ release]; } - - void ShowMessage(const QString& summary, const QString& message, - const QImage& image) { - - NSString* mac_message = - [[NSString alloc] initWithUTF8String:message.toUtf8().constData()]; - NSString* mac_summary = - [[NSString alloc] initWithUTF8String:summary.toUtf8().constData()]; - - NSData* image_data = nil; - // Growl expects raw TIFF data. - // This is nasty but it keeps the API nice. - if (!image.isNull()) { - QByteArray tiff_data; - QBuffer tiff(&tiff_data); - image.save(&tiff, "TIFF"); - image_data = - [NSData dataWithBytes:tiff_data.constData() length:tiff_data.size()]; - } - - [growl_interface_ SendGrowlAlert:mac_message - title:mac_summary - image:image_data]; - - [mac_message release]; - [mac_summary release]; - } - - private: - GrowlInterface* growl_interface_; - ScopedNSAutoreleasePool pool_; -}; - -void OSD::Init() { wrapper_ = new GrowlNotificationWrapper; } - -bool OSD::SupportsNativeNotifications() { return true; } - -bool OSD::SupportsTrayPopups() { return false; } - namespace { bool NotificationCenterSupported() { @@ -152,17 +43,23 @@ void SendNotificationCenterMessage(NSString* title, NSString* subtitle) { } } +void OSD::Init() {} + +bool OSD::SupportsNativeNotifications() { + return NotificationCenterSupported(); +} + +bool OSD::SupportsTrayPopups() { return false; } + + void OSD::ShowMessageNative(const QString& summary, const QString& message, const QString& icon, const QImage& image) { Q_UNUSED(icon); - if (NotificationCenterSupported()) { scoped_nsobject mac_message( [[NSString alloc] initWithUTF8String:message.toUtf8().constData()]); scoped_nsobject mac_summary( [[NSString alloc] initWithUTF8String:summary.toUtf8().constData()]); SendNotificationCenterMessage(mac_summary.get(), mac_message.get()); - } else { - wrapper_->ShowMessage(summary, message, image); } }