Standard Headers

Overview

Certain modules and headers can be included directly within project to instantly add support for Snarl to an application.  In order to maintain a level of consistency, a number of function prototypes are defined which should be implemented by all headers and modules.  The functions are split into two types:
  • Base functions which communicate directly with Snarl;
  • Helper functions which provide wrappers around certain base functions. 
In addition to the defined helper functions, other functions may be included in modules and headers in order to make life easier for the developer.  These will be specific to the individual modules and thus are not documented here.

Conventions used within the modules are as follows:
  • Base functions begin with "sn", use capitalised first letters and do not separate words (e.g. "snDoRequest");
  • Helper functions use all lowercase and separate words with underscores (e.g. "snarl_register").

Using the Modules

How each module is referenced will be specific to the programming language, however here's how to add the currently defined modules to your app:

Delphi

  • Add Snarl.pas to your project

Visual Basic 6

  • Add mSnarl_i.bas to your project

Module Reference

Base Functions

snAppMsg()

int32 snAppMsg()

Returns the identifier of Snarl's application registered Windows message.


snDoRequest()

int32 snDoRequest(str Request, int32 ReplyTimeout = 1000)

Sends Request to Snarl.  ReplyTimeout indicates the number of milliseconds to wait before assuming a reply will not be received.  See the API Reference for more details on the request format and supported commands.


snGetConfigPath()

int32 snGetConfigPath(str Request, int32 ReplyTimeout = 1000)

Sends Request to Snarl.  ReplyTimeout indicates the number of milliseconds to wait before assuming a reply will not be received.  See the API Reference for more details on the request format and supported commands.


snIsSnarlRunning()

bool snIsSnarlRunning()

Returns TRUE if Snarl is running, FALSE otherwise.


snSysMsg()

int32 snSysMsg()

Returns the identifier of Snarl's system registered Windows message.


Helper Functions

snarl_add_class()

int32 snarl_add_class(str Signaturestr IDstr Namebool Enabled = FALSEstr Password = "")

Wraps the addclass command.

snarl_hide_notification()

int32 snarl_hide_notification(str Signaturestr UIDstr Password = "")

Hides the specified notification.

snarl_notify()

int32 snarl_notify(str Signaturestr Classstr UIDstr Password = ""str Title = ""str Text = ""str Icon = ""int32 Priority = 0int32 Duration = -1str Callback = ""int32 PercentValue = -1str CustomData = "")

Provides a wrapper around the most common functionality provided by the notify command.  See the API documentation for a more detailed explanation of the individual arguments.

snarl_register()

int32 snarl_register(str Signaturestr Namestr Iconstr Password = ""int32 ReplyTo = 0, int32 ReplyWith = 0, bool IsDaemon = FALSE)

Registers an application with Snarl.

snarl_unregister()

int32 snarl_unregister(str Signaturestr Password = "")

Unregisters the application previously registered with Signature.  If a password was provided when the application was registered, the same password must be provided in Password.

snarl_version()

int32 snarl_version()

Returns the version number of the currently running Snarl instance.

Examples

VB6

  1. Launch the VB6 IDE
  2. Create a new project
  3. Add mSnarl_i.bas to the project
  4. Add two CommandButtons to Form1
  5. In the code for Form1, enter the following:
Private Sub Command1_Click()

snarl_register "test/test", "My Test App", ""
snarl_ez_notify "test/test", "", "Hello, World!"

End Sub

Private Sub Command2_Click()

snarl_unregister "test/test" 

End Sub
  1. Ensure Snarl is running
  2. Run the project
  3. Click button Command1
  4. Click button Command2
  5. Close Form1 to return to the VB IDE

Comments