2010-11-23 12:42:19 +01:00
|
|
|
/* This file is part of Clementine.
|
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
|
|
|
|
|
|
|
Clementine is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2010-02-24 22:44:14 +01:00
|
|
|
#include "osd.h"
|
|
|
|
|
2015-02-18 17:22:01 +01:00
|
|
|
#import <Foundation/NSUserNotification.h>
|
|
|
|
|
2010-02-24 22:44:14 +01:00
|
|
|
#include <QBuffer>
|
|
|
|
#include <QByteArray>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QtDebug>
|
|
|
|
|
2012-09-13 16:15:28 +02:00
|
|
|
#include "core/scoped_nsobject.h"
|
2012-01-31 13:54:03 +01:00
|
|
|
|
2012-09-13 16:15:28 +02:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
void SendNotificationCenterMessage(NSString* title, NSString* subtitle) {
|
2015-02-18 17:22:01 +01:00
|
|
|
NSUserNotificationCenter* notification_center =
|
|
|
|
[NSUserNotificationCenter defaultUserNotificationCenter];
|
2012-09-13 16:15:28 +02:00
|
|
|
|
2015-02-18 17:22:01 +01:00
|
|
|
NSUserNotification* notification = [[NSUserNotification alloc] init];
|
2014-01-30 14:48:49 +01:00
|
|
|
[notification setTitle:title];
|
|
|
|
[notification setSubtitle:subtitle];
|
2012-09-13 16:15:28 +02:00
|
|
|
|
2014-01-30 14:48:49 +01:00
|
|
|
[notification_center deliverNotification:notification];
|
2012-09-13 16:15:28 +02:00
|
|
|
}
|
2015-02-18 17:22:01 +01:00
|
|
|
|
|
|
|
} // namespace
|
2012-09-13 16:15:28 +02:00
|
|
|
|
2014-04-07 14:54:10 +02:00
|
|
|
void OSD::Init() {}
|
|
|
|
|
2015-02-18 17:22:01 +01:00
|
|
|
bool OSD::SupportsNativeNotifications() { return true; }
|
2014-04-07 14:54:10 +02:00
|
|
|
|
|
|
|
bool OSD::SupportsTrayPopups() { return false; }
|
|
|
|
|
2010-02-24 22:44:14 +01:00
|
|
|
void OSD::ShowMessageNative(const QString& summary, const QString& message,
|
2010-03-30 02:08:16 +02:00
|
|
|
const QString& icon, const QImage& image) {
|
2010-02-24 22:44:14 +01:00
|
|
|
Q_UNUSED(icon);
|
2015-02-18 17:22:01 +01:00
|
|
|
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());
|
2010-02-24 22:44:14 +01:00
|
|
|
}
|