Remove Growl support.

This commit is contained in:
John Maguire 2014-04-07 14:54:10 +02:00
parent 57e4217ccc
commit 712d8ecd8a
4 changed files with 9 additions and 123 deletions

View File

@ -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)

View File

@ -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"

View File

@ -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<OrgFreedesktopNotificationsInterface> interface_;
uint notification_id_;

View File

@ -22,117 +22,8 @@
#include <QFile>
#include <QtDebug>
#import <GrowlApplicationBridge.h>
#include "core/scoped_nsautorelease_pool.h"
#include "core/scoped_nsobject.h"
@interface GrowlInterface : NSObject<GrowlApplicationBridgeDelegate> {
}
- (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<NSString> mac_message(
[[NSString alloc] initWithUTF8String:message.toUtf8().constData()]);
scoped_nsobject<NSString> mac_summary(
[[NSString alloc] initWithUTF8String:summary.toUtf8().constData()]);
SendNotificationCenterMessage(mac_summary.get(), mac_message.get());
} else {
wrapper_->ShowMessage(summary, message, image);
}
}