added osxnotificationcenter backend plugin (does not work yet)

This commit is contained in:
kevin.urban 2014-02-24 19:00:58 +01:00 committed by Patrick von Reth
parent 750cf51566
commit 8ed4053554
6 changed files with 115 additions and 0 deletions

View File

@ -4,3 +4,4 @@ add_subdirectory(growl)
add_subdirectory(trayicon)
add_subdirectory(snoretoast)
add_subdirectory(snore)
add_subdirectory(osxnotificationcenter)

View File

@ -0,0 +1,12 @@
if(APPLE)
message(STATUS "adding osx notification center backend")
#find_library(FOUNDATION Foundation)
set(OSXNOTIFICATIONCENTER_SRC
osxnotificationcenter.mm
#NotificationCenterDelegate.m
)
add_library(libsnore_backend_osxnotificationcenter MODULE ${OSXNOTIFICATIONCENTER_SRC})
#target_link_libraries(libsnore_backend_osxnotificationcenter snorecore ${FOUNDATION})
target_link_libraries(libsnore_backend_osxnotificationcenter snorecore /System/Library/Frameworks/Foundation.framework)
install(TARGETS libsnore_backend_osxnotificationcenter ${SNORE_PLUGIN_INSTALL_PATH})
endif(APPLE)

View File

@ -0,0 +1,8 @@
#import <Foundation/Foundation.h>
#import <Foundation/NSUserNotification.h>
@interface NotificationCenterDelegate : NSObject <NSUserNotificationCenterDelegate> {
// no instance variables
}
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification;
@end

View File

@ -0,0 +1,10 @@
#import "NotificationCenterDelegate.h"
@implementation NotificationCenterDelegate
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification
{
return YES;
}
@end

View File

@ -0,0 +1,41 @@
/*
SnoreNotify is a Notification Framework based on Qt
Copyright (C) 2013-2014 Patrick von Reth <vonreth@kde.org>
SnoreNotify is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SnoreNotify 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OSXNOTIFICATIONCENTER_H
#define OSXNOTIFICATIONCENTER_H
#include "core/plugins/snorebackend.h"
class OSXNotificationCenter : public Snore::SnoreBackend
{
Q_OBJECT
Q_INTERFACES(Snore::SnoreBackend)
Q_PLUGIN_METADATA(IID "org.Snore.NotificationBackend/1.0")
public:
OSXNotificationCenter();
~OSXNotificationCenter();
virtual bool initialize(Snore::SnoreCore *snore);
public slots:
virtual void slotNotify (Snore::Notification notification);
};
#endif // OSXNOTIFICATIONCENTER_H

View File

@ -0,0 +1,43 @@
#include "osxnotificationcenter.h"
#include "core/plugins/snorebackend.h"
#import <Foundation/NSUserNotification.h>
//#import "NotificationCenterDelegate.h"
Q_EXPORT_PLUGIN2(libsnore_backend_osxnotificationcenter, OSXNotificationCenter)
using namespace Snore;
namespace {
NSUserNotificationCenter *notification_center;
//NotificationCenterDelegate *notification_center_delegate;
}
OSXNotificationCenter::OSXNotificationCenter() : SnoreBackend("OSX Notification Center", false, false, false)
{
}
OSXNotificationCenter::~OSXNotificationCenter()
{
}
bool OSXNotificationCenter::initialize(SnoreCore *snore)
{
notification_center = [NSUserNotificationCenter defaultUserNotificationCenter];
//notification_center_delegate = [[NotificationCenterDelegate alloc] init];
//[notification_center setDelegate:notification_center_delegate];
return SnoreBackend::initialize(snore);
}
void OSXNotificationCenter::slotNotify(Snore::Notification notification)
{
NSUserNotification *osx_notification = [[NSUserNotification alloc] init];
osx_notification.title = @"Test";
osx_notification.informativeText = @"Hello";
[notification_center deliverNotification: osx_notification];
[osx_notification release];
}