summaryrefslogtreecommitdiff
path: root/src/lib/ecore_cocoa/ecore_cocoa_notification.m
blob: ee0a2a923ce9dbbdee7a261fccb1e30eabad07d0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#import <Cocoa/Cocoa.h>

#include "Ecore_Cocoa.h"
#include "ecore_cocoa_window.h"
#include "ecore_cocoa_private.h"

@interface EcoreCocoaNotificationDelegate: NSObject <NSUserNotificationCenterDelegate>
@end

@implementation EcoreCocoaNotificationDelegate

- (void)userNotificationCenter:(NSUserNotificationCenter *)center
        didDeliverNotification:(NSUserNotification *)notification
{
   NSLog(@"Hey, I just met you...\n");
}

@end

struct _Ecore_Cocoa_Notification
{
   NSUserNotification *ref;
   unsigned int uid;
};

EAPI void
ecore_cocoa_notification_send(Ecore_Cocoa_Notification *replaces EINA_UNUSED,
                              const char *name,
                              const char *description,
                              const char *icon EINA_UNUSED,
                              Ecore_Cocoa_Notify_Send_Cb cb,
                              const void *cb_data)
{
   NSUserNotification *const n = [[NSUserNotification alloc] init];
   n.title = [NSString stringWithUTF8String: name];
   n.informativeText = [NSString stringWithUTF8String: description];
   [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification: n];
}

EAPI Ecore_Cocoa_Notification *
ecore_cocoa_notification_get(unsigned int uid)
{
   if (!uid) return NULL;
   CRI("NOT IMPLEMENTED!!!!\n");
   return NULL; /* TODO FIXME */
}

void
ecore_cocoa_notification_close(Ecore_Cocoa_Notification *n EINA_UNUSED)
{
   CRI("Not implemented");
}

Eina_Bool
_ecore_cocoa_notification_init(void)
{
  // NSUserNotificationCenter *def;
  // EcoreCocoaNotificationDelegate *delegate;

  // def = [NSUserNotificationCenter defaultUserNotificationCenter];
  // delegate = [[EcoreCocoaNotificationDelegate alloc] init];
  // if (EINA_UNLIKELY(delegate == nil))
  //   {
  //      CRI("Failed to create delegate of user notification center");
  //      return EINA_FALSE;
  //   }
  // def.delegate = delegate;

   return EINA_TRUE;
}

void
_ecore_cocoa_notification_shutdown(void)
{
  // NSUserNotificationCenter *def;
  // EcoreCocoaNotificationDelegate *delegate;

  // def = [NSUserNotificationCenter defaultUserNotificationCenter];
  // delegate = def.delegate;
  // [delegate release];
  // def.delegate = nil;
}