COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
growl++.cpp
Go to the documentation of this file.
1 #include <growl++.hpp>
2 #include <growl.h>
3 #include <stdio.h>
4 #include <string.h>
5 #include <stdlib.h>
6 
7 
8 Growl::Growl(const Growl_Protocol _protocol, const char *const _password, const char *const _application, const char **_notifications, const int _notifications_count)
9 {
10  server = strdup("localhost");
11  if (_password) password = strdup(_password);
12  protocol = _protocol;
13  application = strdup(_application);
14  Register(_notifications, _notifications_count);
15 }
16 
17 
18 Growl::Growl(const Growl_Protocol _protocol, const char *const _server, const char *const _password, const char *const _application, const char **_notifications, const int _notifications_count )
19 {
20  server = strdup(_server);
21  if (_password) password = strdup(_password);
22  protocol = _protocol;
23  application = strdup(_application);
24  Register(_notifications, _notifications_count);
25 }
26 
27 
28 void Growl::Register(const char **const notifications, const int notifications_count , const char *const icon )
29 {
30  if( protocol == GROWL_TCP )
31  {
32  growl_tcp_register( server , application , notifications , notifications_count , password , icon );
33  }
34  else
35  {
36  growl_udp_register( server , application , notifications , notifications_count , password );
37  }
38 }
39 
40 
42 {
43  if(server != NULL)
44  {
45  free(server);
46  }
47  if(password != NULL)
48  {
49  free(password);
50  }
51  if(application == NULL)
52  {
53  free(application);
54  }
55 }
56 
57 
58 void Growl::Notify(const char *const notification, const char *const title, const char* const message)
59 {
60  Growl::Notify(notification, title, message, NULL, NULL);
61 }
62 
63 
64 void Growl::Notify(const char *const notification, const char *const title, const char* const message, const char *const url, const char *const icon)
65 {
66  if( protocol == GROWL_TCP )
67  {
68  growl_tcp_notify( server , application , notification , title , message , password , url , icon );
69  }
70  else
71  {
72  growl_udp_notify( server , application , notification , title , message , password );
73  }
74 }
Growl_Protocol
Definition: growl++.hpp:16
Growl(const Growl_Protocol _protocol, const char *const _password, const char *const _appliciation, const char **const _notifications, const int _notifications_count)
Definition: growl++.cpp:8
char * server
Definition: growl++.hpp:21
GROWL_EXPORT int growl_tcp_notify(const char *const server, const char *const appname, const char *const notify, const char *const title, const char *const message, const char *const password, const char *const url, const char *const icon)
Definition: growl.c:157
char * password
Definition: growl++.hpp:22
void Register(const char **const _notifications, const int _notifications_count, const char *const icon=NULL)
Definition: growl++.cpp:28
Growl_Protocol protocol
Definition: growl++.hpp:24
GROWL_EXPORT int growl_udp_register(const char *const server, const char *const appname, const char **const notifications, const int notifications_count, const char *const password)
Definition: growl.c:231
GROWL_EXPORT int growl_udp_notify(const char *const server, const char *const appname, const char *const notify, const char *const title, const char *const message, const char *const password)
Definition: growl.c:295
char * application
Definition: growl++.hpp:23
~Growl()
Definition: growl++.cpp:41
void Notify(const char *const notification, const char *const title, const char *const message)
Definition: growl++.cpp:58
GROWL_EXPORT int growl_tcp_register(const char *const server, const char *const appname, const char **const notifications, const int notifications_count, const char *const password, const char *const icon)
Definition: growl.c:109
Send comments to:
COOLFluiD Web Admin