Hoa central
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Hoa\Notification\Growl Class Reference
Inheritance diagram for Hoa\Notification\Growl:

Public Member Functions

 __construct ($applicationName= 'Hoa',\Hoa\Socket\Client $client=null, $password= '')
 
 __get ($channel)
 
 notify ($title, $message)
 
 getApplicationName ()
 
 getPassword ()
 
 getChannel ()
 
 getChannels ()
 
 channelExists ($channel)
 

Protected Member Functions

 handshake ()
 
 setApplicationName ($applicationName)
 
 setPassword ($password)
 

Protected Attributes

 $_client = null
 
 $_applicationName = null
 
 $_password = null
 
 $_channel = '_default'
 
 $_channels = array('_default' => false)
 

Detailed Description

Class .

Growl notification support.

Author
Ivan Enderlin ivan..nosp@m.ende.nosp@m.rlin@.nosp@m.hoa-.nosp@m.proje.nosp@m.ct.n.nosp@m.et

Definition at line 70 of file Growl.php.

Constructor & Destructor Documentation

Hoa\Notification\Growl::__construct (   $applicationName = 'Hoa',
\Hoa\Socket\Client  $client = null,
  $password = '' 
)

Construct a new notifier.

public

Parameters
string$applicationNameApplication's name.
\Hoa\Socket\Client$clientClient.
string$passwordApplication's password.
Returns
void
Exceptions

Definition at line 121 of file Growl.php.

123  {
124 
125  if(null === $client)
126  $client = new \Hoa\Socket\Client('udp://localhost:9887');
127 
128  $this->_client = $client;
129  $this->_client->connect();
130  $this->setApplicationName($applicationName);
131  $this->setPassword($password);
132 
133  return;
134  }
setApplicationName($applicationName)
Definition: Growl.php:233
setPassword($password)
Definition: Growl.php:259

Here is the call graph for this function:

Member Function Documentation

Hoa\Notification\Growl::__get (   $channel)

Select a specific channel.

public

Parameters
string$channelChannel's name.
Returns

Definition at line 143 of file Growl.php.

143  {
144 
145  if(false === $this->channelExists($channel))
146  $this->_channels[$channel] = false;
147 
148  $this->_channel = $channel;
149 
150  if(false === $this->_channels[$channel])
151  $this->handshake();
152 
153  return $this;
154  }
channelExists($channel)
Definition: Growl.php:306

Here is the call graph for this function:

Hoa\Notification\Growl::channelExists (   $channel)

Check if a channel exists.

public

Returns
string

Definition at line 306 of file Growl.php.

306  {
307 
308  return array_key_exists($channel, $this->getChannels());
309  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Notification\Growl::getApplicationName ( )

Get application's name.

public

Returns
string

Definition at line 247 of file Growl.php.

247  {
248 
250  }

Here is the caller graph for this function:

Hoa\Notification\Growl::getChannel ( )

Get current channel.

public

Returns
string

Definition at line 284 of file Growl.php.

284  {
285 
286  return $this->_channel;
287  }

Here is the caller graph for this function:

Hoa\Notification\Growl::getChannels ( )

Get all channels.

public

Returns
array

Definition at line 295 of file Growl.php.

295  {
296 
297  return $this->_channels;
298  }

Here is the caller graph for this function:

Hoa\Notification\Growl::getPassword ( )

Get application's password.

public

Returns
string

Definition at line 273 of file Growl.php.

273  {
274 
275  return $this->_password;
276  }

Here is the caller graph for this function:

Hoa\Notification\Growl::handshake ( )
protected

Do handshake.

protected

Returns
bool

Definition at line 162 of file Growl.php.

162  {
163 
164  $channel = $this->getChannel();
165  $data = pack(
166  'c2nc2',
167  1,
168  0,
169  strlen($this->getApplicationName()),
170  1,
171  1
172  ) .
173  $this->getApplicationName() .
174  pack('n', strlen($channel)) . $channel .
175  pack('c', 0);
176 
177  $this->_client->writeAll(
178  $data .
179  pack('H32', md5($data . $this->getPassword()))
180  );
181 
182  $this->_channels[$channel] = true;
183 
184  return true;
185  }

Here is the call graph for this function:

Here is the caller graph for this function:

Hoa\Notification\Growl::notify (   $title,
  $message 
)

Send a notification.

public

Parameters
string$titleTitle.
string$messageMessage.
Returns

Implements Hoa\Notification\Notification.

Definition at line 195 of file Growl.php.

195  {
196 
197  $channel = $this->getChannel();
198 
199  if(false === $this->_channels[$channel]) // _default
200  $this->handshake();
201 
202  $flags = 0;
203  $data = pack(
204  'c2n5',
205  1,
206  1,
207  $flags,
208  strlen($channel),
209  strlen($title),
210  strlen($message),
211  strlen($this->getApplicationName())
212  ) .
213  $channel .
214  $title .
215  $message .
216  $this->getApplicationName();
217 
218  $this->_client->writeAll(
219  $data .
220  pack('H32', md5($data . $this->getPassword()))
221  );
222 
223  return $this;
224  }

Here is the call graph for this function:

Hoa\Notification\Growl::setApplicationName (   $applicationName)
protected

Set application's name.

protected

Parameters
string$applicationNameApplication's name.
Returns
string

Definition at line 233 of file Growl.php.

233  {
234 
236  $this->_applicationName = $applicationName;
237 
238  return $old;
239  }

Here is the caller graph for this function:

Hoa\Notification\Growl::setPassword (   $password)
protected

Set application's password.

protected

Parameters
string$passwordApplication's password.
Returns
string

Definition at line 259 of file Growl.php.

259  {
260 
261  $old = $this->_password;
262  $this->_password = $password;
263 
264  return $old;
265  }

Here is the caller graph for this function:

Member Data Documentation

Hoa\Notification\Growl::$_applicationName = null
protected

Definition at line 84 of file Growl.php.

Hoa\Notification\Growl::$_channel = '_default'
protected

Definition at line 98 of file Growl.php.

Hoa\Notification\Growl::$_channels = array('_default' => false)
protected

Definition at line 106 of file Growl.php.

Hoa\Notification\Growl::$_client = null
protected

Definition at line 77 of file Growl.php.

Hoa\Notification\Growl::$_password = null
protected

Definition at line 91 of file Growl.php.


The documentation for this class was generated from the following file: