Table A.1. All classes
| Name | Description |
|---|---|
A PHP library that talk to Growl | |
Application object for Net_Growl | |
Dedicated Exception for Net_Growl | |
UDP adapter | |
GNTP adapter | |
GNTP Mock adapter intended for test only | |
GNTP specialized response |
<?php
class Net_Growl
{
/* constants */
const int UDP_PORT;
const int GNTP_PORT;
const int PRIORITY_LOW;
const int PRIORITY_MODERATE;
const int PRIORITY_NORMAL;
const int PRIORITY_HIGH;
const int PRIORITY_EMERGENCY;
/* properties */
protected array $options;
protected array $growlNotificationCallback;
protected int $growlNotificationCount;
protected bool $isRegistered;
protected static object $instance;
private object $_application;
private int $_growlNotificationLimit;
private resource $_fp;
/* methods */
public static final object singleton(mixed &$application, array $notifications [, string $password = '' [, array $options = array()]] );
public static final void reset();
public void __destruct();
public void setNotificationLimit($max);
public object getApplication();
public bool | Net_Growl_Response register();
public bool | Net_Growl_Response notify(string $name, string $title [, string $description = '' [, array $options = array()]] )
public string getDefaultGrowlIcon([ bool $return = true [, string $ver = '2']]);
public static void autoload($class);
public void errorHandler(int $errno, string $errstr, string $errfile, int $errline);
protected object __construct(mixed &$application, array $notifications [, string $password = '' [, array $options = array()]] );
protected bool | Net_Growl_Response sendRequest(string $method, mixed $data [, bool $callback = false] );
protected void debug(string $message [, string $priority = 'debug']);
protected string utf8Encode($data);
protected int strByteLen($string);
private string _readLine(resource $fp);
}Table A.2. Net_Growl Constants
| Name | Value | Description |
|---|---|---|
UDP_PORT | 9887 | Growl default UDP port |
GNTP_PORT | 23053 | Growl default GNTP port |
PRIORITY_LOW | -2 | Growl low priority |
PRIORITY_MODERATE | -1 | Growl moderate priority |
PRIORITY_NORMAL | 0 | Growl normal priority |
PRIORITY_HIGH | 1 | Growl high priority |
PRIORITY_EMERGENCY | 2 | Growl emergency priority |
Table A.3. Net_Growl Methods
| Name | Description |
|---|---|
Makes sure there is only one Growl connection open | |
Limit the number of notifications | |
Returns the registered application object | |
Sends a application register to Growl | |
Sends a notification to Growl | |
Returns Growl default icon logo binary data | |
Autoloader for PEAR compatible classes | |
Converts standard error into exception |
Description. Makes sure there is only one Growl connection open.
Parameter
(optional) List of options :
host, port, protocol, timeout
passwordHashAlgorithm, encryptionAlgorithm
debug
Throws
Return value. object - Net_Growl
Description. This method limits the number of notifications to be displayed on the Growl user desktop. By default, there is no limit. It is used mostly to prevent problem with notifications within loops.
Parameter
Throws. no exceptions thrown
Return value. void
Description. Returns the registered application object
Throws. no exceptions thrown
Return value. object - Net_Growl_Application
Description. Sends a application register to Growl
Throws
Return value. void
Description. Sends a notification to Growl
Growl notifications have a name, a title, a description and a few options, depending on the kind of display plugin you use. The bubble plugin is recommended, until there is a plugin more appropriate for these kind of notifications.
The current options supported by most Growl plugins are:
<?php
array('priority' => 0, 'sticky' => false);Parameter
Throws
Return value. bool - true
Description. Returns Growl default icon logo binary data. Decodes data encoded with MIME base64
Parameter
Throws. no exceptions thrown
Return value. string - icon logo binary data
Example A.1. Display Growl Icon
<?php require_once 'Net/Growl/Autoload.php'; Net_Growl::getDefaultGrowlIcon(false); ?>
Description. Autoloader for PEAR compatible classes
Parameter
Throws
Return value. void
Description. Throws ErrorException when a standard error occured with severity level we are asking for (uses error_reporting)
Parameter
Throws
Return value. void
<?php
class Net_Growl_Application
{
/* properties */
private string $_growlAppName;
private string $_growlAppPassword;
private string $_growlAppIcon;
private array $_growlNotifications;
/* methods */
public object __construct([mixed $appName = null [, array $notifications = null [, string $password = null [, string $appIcon = null]]]] );
public void addGrowlNotifications(array $notifications);
public array getGrowlNotifications();
public string setGrowlName(string $appName);
public string getGrowlName();
public string setGrowlPassword(string $password);
public string getGrowlPassword();
public string setGrowlIcon(string $appIcon);
public string getGrowlIcon();
}Table A.4. Net_Growl_Application Methods
| Name | Description |
|---|---|
Constructs a new application to be registered by Growl | |
Adds notifications supported by this application | |
Returns the notifications accepted by Growl for this application | |
Sets the application name for registration in Growl | |
Returns the application name for registration in Growl | |
Sets the password to be used by Growl to accept notification packets | |
Returns the password to be used by Growl to accept notification packets | |
Sets the application icon for registration in Growl | |
Returns the application icon for registration in Growl |
Description. Constructs a new application to be registered by Growl
Parameter
Throws. no exceptions thrown
Return value. object - Net_Growl_Application
Example A.2. PEAR_Error growl handler
<?php
require_once 'Net/Growl/Autoload.php';
require_once 'PEAR.php';
define('GROWL_NOTIFY_PEARERROR', 'PEAR_Error');
function growlErrors($error)
{
static $app;
if (!isset($app)) {
$app = new Net_Growl_Application(
'Net_Growl', array(GROWL_NOTIFY_PEARERROR), 'mamasam'
);
}
$growl = Net_Growl::singleton(
$app, null, null, array('host' => '127.0.0.1')
);
$growl->notify(GROWL_NOTIFY_PEARERROR,
get_class($error),
$error->message.' in '.$_SERVER['SCRIPT_NAME'],
array('sticky' => true)
);
}
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'growlErrors');
PEAR::raiseError("The expected error you submitted does not exist");
?>Description. Adds notifications supported by this application
Expected array format is:
<?php
array('notification name' => array('option name' => 'option value'));At the moment, only option name enabled is supported. Example:
<?php
$notifications = array('Test Notification' => array('enabled' => true));Parameter
Throws. InvalidArgumentException
Return value. void
Description. Returns the notifications accepted by Growl for this application
Expected array format is:
<?php
array('notification name' => array('option name' => 'option value'));At the moment, only option name enabled is supported. Example:
<?php
$notifications = array('Test Notification' => array('enabled' => true));
return $notifications;Throws. no exceptions thrown
Return value. array - list of notifications type
Description. Sets the application name for registration in Growl
Throws. InvalidArgumentException
Return value. void
Description. Returns the application name for registration in Growl
Throws. no exceptions thrown
Return value. string — application name
Description. Sets the password to be used by Growl to accept notification packets
Throws. InvalidArgumentException
Return value. void
Description. Returns the password to be used by Growl to accept notification packets
Throws. no exceptions thrown
Return value. string — password
Description. Sets the application icon for registration in Growl
Throws. InvalidArgumentException
Return value. void
Inherit all methods and properties from base Exception class. More details at http://www.php.net/manual/en/class.exception.php |
<?php
class Net_Growl_Udp
{
/* methods */
public object __construct(mixed $application [, array $notifications = array() [, string $password = '' [, array $options = array()]]] );
public bool sendRegister();
public bool sendNotify($name, $title, $description, $options);
}Table A.5. Net_Growl_Udp Methods
| Name | Description |
|---|---|
Constructs a new UDP adapter | |
Sends the REGISTER message type | |
Sends the NOTIFY message type |
Description. Constructs a new UDP adapter
Parameter
(optional) List of options :
host, port, protocol, timeout
debug
Throws. no exceptions thrown
Return value. object - Net_Growl_Udp
Description. Sends the REGISTER message type
Throws
Return value. true
<?php
class Net_Growl_Gntp
{
/* properties */
private array $_passwordHashAlgorithm;
/* methods */
public object __construct(mixed $application [, array $notifications = array() [, string $password = '' [, array $options = array()]]] );
public Net_Growl_Response sendRegister();
public Net_Growl_Response sendNotify($name, $title, $description, $options);
protected string genMessageStructure($method, $data [, $binaries = false]);
private array _genKey($password);
private array _genEncryption($key, $plainText);
private string _toBool($value);
}Table A.6. Net_Growl_Gntp Methods
| Name | Description |
|---|---|
Constructs a new GNTP adapter | |
Sends the REGISTER message type | |
Sends the NOTIFY message type |
Description. Constructs a new GNTP adapter
Parameter
(optional) List of options :
host, port, protocol, timeout
passwordHashAlgorithm, encryptionAlgorithm
debug
Throws. no exceptions thrown
Return value. object - Net_Growl_Gntp
Description. Sends the REGISTER message type
Throws
Return value. Net_Growl_Response object
<?php
class Net_Growl_GntpMock
{
/* properties */
protected $responses = array();
/* methods */
public object __construct(mixed $application [, array $notifications = array() [, string $password = '' [, array $options = array()]]] );
public Net_Growl_Response sendRegister();
public Net_Growl_Response sendNotify($name, $title, $description, $options);
public void addResponse($response)
protected Net_Growl_Response sendRequest()
protected Net_Growl_Response createResponseFromString($str)
protected Net_Growl_Response createResponseFromFile($fp)
}Table A.7. Net_Growl_GntpMock Methods
| Name | Description |
|---|---|
Constructs a new GNTP Mock adapter | |
Mock sending the REGISTER message type | |
Mock sending the NOTIFY message type | |
Adds response to the queue |
Description. Constructs a new GNTP adapter
Parameter
(optional) List of options :
host, port, protocol, timeout
passwordHashAlgorithm, encryptionAlgorithm
debug
Throws. no exceptions thrown
Return value. object - Net_Growl_GntpMock
Description. Mock sending the REGISTER message type
Throws
Return value. Net_Growl_Response object
Description. Mock sending the NOTIFY message type
Throws
Return value. Net_Growl_Response object
<?php
class Net_Growl_Response
{
/* properties */
protected string $version;
protected string $code;
protected string $action;
protected integer $errorCode;
protected string $errorDescription;
protected string $machineName;
protected string $softwareName;
protected string $softwareVersion;
protected string $platformName;
protected string $platformVersion;
protected string $body;
/* methods */
public object __construct(string $statusLine );
public void appendBody(string $bodyChunk );
public string getVersion();
public string getStatus();
public string getResponseAction();
public integer getErrorCode();
public string getErrorDescription();
public string getOriginMachineName();
public string getOriginSoftwareName();
public string getOriginSoftwareVersion();
public string getOriginPlatformName();
public string getOriginPlatformVersion();
public string __toString();
}Table A.8. Net_Growl_Response Methods
| Name | Description |
|---|---|
Constructs a new GNTP specialized response | |
Append a string to the response body | |
Returns GNTP protocol version | |
Returns the status code | |
Returns the request action | |
Returns the error code | |
Returns the error description | |
Returns the machine name/host name of the sending computer | |
Returns the identity of the sending framework | |
Returns the version of the sending framework | |
Returns the identify of the sending computer OS/platform | |
Returns the version of the sending computer OS/platform | |
Returns the String representation of the Growl response |
Description. Constructs a specialized response to a GNTP request
Parameter
Throws. no exceptions thrown
Return value. object - Net_Growl_Response
Description. Append a string to the response body excluding the protocol identifier, version, message type, and encryption algorithm id
Throws. no exceptions thrown
Return value. void
Description. Returns GNTP protocol version (e.g. 1.0, 1.1)
Throws. no exceptions thrown
Return value. string
Description. Returns the status code (OK | ERROR)
Throws. no exceptions thrown
Return value. string
Description. Returns the request action (REGITER | NOTIFY)
Throws. no exceptions thrown
Return value. string
Description. Returns the error code
Throws. no exceptions thrown
Return value. integer
Description. Returns the error description
Throws. no exceptions thrown
Return value. string
Description. Returns the machine name/host name of the sending computer
Throws. no exceptions thrown
Return value. string
Description. Returns the identity of the sending framework
Throws. no exceptions thrown
Return value. string
Description. Returns the version of the sending framework
Throws. no exceptions thrown
Return value. string
Description. Returns the identify of the sending computer OS/platform
Throws. no exceptions thrown
Return value. string
Description. Returns the version of the sending computer OS/platform
Throws. no exceptions thrown
Return value. string