Skip to content

Commit f151f5f

Browse files
committed
[macOS] remove Growl support, remove unused code
1 parent a3624dd commit f151f5f

File tree

4 files changed

+2
-88
lines changed

4 files changed

+2
-88
lines changed

src/qt/macnotificationhandler.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,17 @@
77

88
#include <QObject>
99

10-
/** Macintosh-specific notification handler (supports UserNotificationCenter and Growl).
10+
/** Macintosh-specific notification handler (supports UserNotificationCenter).
1111
*/
1212
class MacNotificationHandler : public QObject
1313
{
1414
Q_OBJECT
1515

1616
public:
17-
/** shows a 10.8+ UserNotification in the UserNotificationCenter
17+
/** shows a macOS 10.8+ UserNotification in the UserNotificationCenter
1818
*/
1919
void showNotification(const QString &title, const QString &text);
2020

21-
/** executes AppleScript */
22-
void sendAppleScript(const QString &script);
23-
2421
/** check if OS can handle UserNotifications */
2522
bool hasUserNotificationCenterSupport(void);
2623
static MacNotificationHandler *instance();

src/qt/macnotificationhandler.mm

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,6 @@ - (NSString *)__bundleIdentifier
4747
}
4848
}
4949

50-
// sendAppleScript just take a QString and executes it as apple script
51-
void MacNotificationHandler::sendAppleScript(const QString &script)
52-
{
53-
QByteArray utf8 = script.toUtf8();
54-
char* cString = (char *)utf8.constData();
55-
NSString *scriptApple = [[NSString alloc] initWithUTF8String:cString];
56-
57-
NSAppleScript *as = [[NSAppleScript alloc] initWithSource:scriptApple];
58-
NSDictionary *err = nil;
59-
[as executeAndReturnError:&err];
60-
[as release];
61-
[scriptApple release];
62-
}
63-
6450
bool MacNotificationHandler::hasUserNotificationCenterSupport(void)
6551
{
6652
Class possibleClass = NSClassFromString(@"NSUserNotificationCenter");

src/qt/notificator.cpp

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,6 @@ Notificator::Notificator(const QString &_programName, QSystemTrayIcon *_trayIcon
6060
if( MacNotificationHandler::instance()->hasUserNotificationCenterSupport()) {
6161
mode = UserNotificationCenter;
6262
}
63-
else {
64-
// Check if Growl is installed (based on Qt's tray icon implementation)
65-
CFURLRef cfurl;
66-
OSStatus status = LSGetApplicationForInfo(kLSUnknownType, kLSUnknownCreator, CFSTR("growlTicket"), kLSRolesAll, 0, &cfurl);
67-
if (status != kLSApplicationNotFoundErr) {
68-
CFBundleRef bundle = CFBundleCreate(0, cfurl);
69-
if (CFStringCompare(CFBundleGetIdentifier(bundle), CFSTR("com.Growl.GrowlHelperApp"), kCFCompareCaseInsensitive | kCFCompareBackwards) == kCFCompareEqualTo) {
70-
if (CFStringHasSuffix(CFURLGetString(cfurl), CFSTR("/Growl.app/")))
71-
mode = Growl13;
72-
else
73-
mode = Growl12;
74-
}
75-
CFRelease(cfurl);
76-
CFRelease(bundle);
77-
}
78-
}
7963
#endif
8064
}
8165

@@ -241,52 +225,6 @@ void Notificator::notifySystray(Class cls, const QString &title, const QString &
241225

242226
// Based on Qt's tray icon implementation
243227
#ifdef Q_OS_MAC
244-
void Notificator::notifyGrowl(Class cls, const QString &title, const QString &text, const QIcon &icon)
245-
{
246-
const QString script(
247-
"tell application \"%5\"\n"
248-
" set the allNotificationsList to {\"Notification\"}\n" // -- Make a list of all the notification types (all)
249-
" set the enabledNotificationsList to {\"Notification\"}\n" // -- Make a list of the notifications (enabled)
250-
" register as application \"%1\" all notifications allNotificationsList default notifications enabledNotificationsList\n" // -- Register our script with Growl
251-
" notify with name \"Notification\" title \"%2\" description \"%3\" application name \"%1\"%4\n" // -- Send a Notification
252-
"end tell"
253-
);
254-
255-
QString notificationApp(QApplication::applicationName());
256-
if (notificationApp.isEmpty())
257-
notificationApp = "Application";
258-
259-
QPixmap notificationIconPixmap;
260-
if (icon.isNull()) { // If no icon specified, set icon based on class
261-
QStyle::StandardPixmap sicon = QStyle::SP_MessageBoxQuestion;
262-
switch (cls)
263-
{
264-
case Information: sicon = QStyle::SP_MessageBoxInformation; break;
265-
case Warning: sicon = QStyle::SP_MessageBoxWarning; break;
266-
case Critical: sicon = QStyle::SP_MessageBoxCritical; break;
267-
}
268-
notificationIconPixmap = QApplication::style()->standardPixmap(sicon);
269-
}
270-
else {
271-
QSize size = icon.actualSize(QSize(48, 48));
272-
notificationIconPixmap = icon.pixmap(size);
273-
}
274-
275-
QString notificationIcon;
276-
QTemporaryFile notificationIconFile;
277-
if (!notificationIconPixmap.isNull() && notificationIconFile.open()) {
278-
QImageWriter writer(&notificationIconFile, "PNG");
279-
if (writer.write(notificationIconPixmap.toImage()))
280-
notificationIcon = QString(" image from location \"file://%1\"").arg(notificationIconFile.fileName());
281-
}
282-
283-
QString quotedTitle(title), quotedText(text);
284-
quotedTitle.replace("\\", "\\\\").replace("\"", "\\");
285-
quotedText.replace("\\", "\\\\").replace("\"", "\\");
286-
QString growlApp(this->mode == Notificator::Growl13 ? "Growl" : "GrowlHelperApp");
287-
MacNotificationHandler::instance()->sendAppleScript(script.arg(notificationApp, quotedTitle, quotedText, notificationIcon, growlApp));
288-
}
289-
290228
void Notificator::notifyMacUserNotificationCenter(Class cls, const QString &title, const QString &text, const QIcon &icon) {
291229
// icon is not supported by the user notification center yet. OSX will use the app icon.
292230
MacNotificationHandler::instance()->showNotification(title, text);
@@ -310,10 +248,6 @@ void Notificator::notify(Class cls, const QString &title, const QString &text, c
310248
case UserNotificationCenter:
311249
notifyMacUserNotificationCenter(cls, title, text, icon);
312250
break;
313-
case Growl12:
314-
case Growl13:
315-
notifyGrowl(cls, title, text, icon);
316-
break;
317251
#endif
318252
default:
319253
if(cls == Critical)

src/qt/notificator.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ public Q_SLOTS:
5858
None, /**< Ignore informational notifications, and show a modal pop-up dialog for Critical notifications. */
5959
Freedesktop, /**< Use DBus org.freedesktop.Notifications */
6060
QSystemTray, /**< Use QSystemTray::showMessage */
61-
Growl12, /**< Use the Growl 1.2 notification system (Mac only) */
62-
Growl13, /**< Use the Growl 1.3 notification system (Mac only) */
6361
UserNotificationCenter /**< Use the 10.8+ User Notification Center (Mac only) */
6462
};
6563
QString programName;
@@ -72,7 +70,6 @@ public Q_SLOTS:
7270
#endif
7371
void notifySystray(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout);
7472
#ifdef Q_OS_MAC
75-
void notifyGrowl(Class cls, const QString &title, const QString &text, const QIcon &icon);
7673
void notifyMacUserNotificationCenter(Class cls, const QString &title, const QString &text, const QIcon &icon);
7774
#endif
7875
};

0 commit comments

Comments
 (0)