Profanity C Plugin API
Typedefs | Functions
profapi.h File Reference

Go to the source code of this file.

Typedefs

typedef char * PROF_WIN_TAG
 
typedef void(* CMD_CB) (char **args)
 
typedef void(* TIMED_CB) (void)
 
typedef void(* WINDOW_CB) (PROF_WIN_TAG win, char *line)
 

Functions

void prof_cons_alert (void)
 
int prof_cons_show (const char *const message)
 
int prof_cons_show_themed (const char *const group, const char *const item, const char *const def, const char *const message)
 
int prof_cons_bad_cmd_usage (const char *const cmd)
 
void prof_register_command (const char *command_name, int min_args, int max_args, char **synopsis, const char *description, char *arguments[][2], char **examples, CMD_CB callback)
 
void prof_register_timed (TIMED_CB callback, int interval_seconds)
 
void prof_completer_add (const char *key, char **items)
 
void prof_completer_remove (const char *key, char **items)
 
void prof_completer_clear (const char *key)
 
void prof_filepath_completer_add (const char *prefix)
 
void prof_notify (const char *message, int timeout_ms, const char *category)
 
void prof_send_line (char *line)
 
char * prof_get_current_recipient (void)
 
char * prof_get_current_muc (void)
 
int prof_current_win_is_console (void)
 
char * prof_get_current_nick (void)
 
char ** prof_get_current_occupants (void)
 
char * prof_get_room_nick (const char *barejid)
 
void prof_log_debug (const char *message)
 
void prof_log_info (const char *message)
 
void prof_log_warning (const char *message)
 
void prof_log_error (const char *message)
 
void prof_win_create (PROF_WIN_TAG win, WINDOW_CB input_handler)
 
int prof_win_exists (PROF_WIN_TAG win)
 
int prof_win_focus (PROF_WIN_TAG win)
 
int prof_win_show (PROF_WIN_TAG win, char *message)
 
int prof_win_show_themed (PROF_WIN_TAG tag, char *group, char *key, char *def, char *message)
 
int prof_send_stanza (char *stanza)
 
int prof_settings_boolean_get (char *group, char *key, int def)
 
void prof_settings_boolean_set (char *group, char *key, int value)
 
char * prof_settings_string_get (char *group, char *key, char *def)
 
void prof_settings_string_set (char *group, char *key, char *value)
 
char ** prof_settings_string_list_get (char *group, char *key)
 
void prof_settings_string_list_add (char *group, char *key, char *value)
 
int prof_settings_string_list_remove (char *group, char *key, char *value)
 
int prof_settings_string_list_clear (char *group, char *key)
 
int prof_settings_int_get (char *group, char *key, int def)
 
void prof_settings_int_set (char *group, char *key, int value)
 
void prof_incoming_message (char *barejid, char *resource, char *message)
 
void prof_disco_add_feature (char *feature)
 
void prof_encryption_reset (char *barejid)
 
int prof_chat_set_titlebar_enctext (char *barejid, char *enctext)
 
int prof_chat_unset_titlebar_enctext (char *barejid)
 
int prof_chat_set_incoming_char (char *barejid, char *ch)
 
int prof_chat_unset_incoming_char (char *barejid)
 
int prof_chat_set_outgoing_char (char *barejid, char *ch)
 
int prof_chat_unset_outgoing_char (char *barejid)
 
int prof_room_set_titlebar_enctext (char *roomjid, char *enctext)
 
int prof_room_unset_titlebar_enctext (char *roomjid)
 
int prof_room_set_message_char (char *roomjid, char *ch)
 
int prof_room_unset_message_char (char *roomjid)
 
int prof_chat_show (char *barejid, char *message)
 
int prof_chat_show_themed (char *barejid, char *group, char *item, char *def, char *ch, char *message)
 
int prof_room_show (char *roomjid, char *message)
 
int prof_room_show_themed (char *roomjid, char *group, char *item, char *def, char *ch, char *message)
 

Detailed Description

C plugin API.

Typedef Documentation

typedef void(* CMD_CB) (char **args)

Type representing a function pointer to a command callback

typedef char* PROF_WIN_TAG

Type representing a window, used for referencing windows created by the plugin

typedef void(* TIMED_CB) (void)

Type representing a function pointer to a timed callback

typedef void(* WINDOW_CB) (PROF_WIN_TAG win, char *line)

Type representing a function pointer to a window callback

Function Documentation

int prof_chat_set_incoming_char ( char *  barejid,
char *  ch 
)

Set the incoming message prefix character for specified contact.

Parameters
barejidJabber ID of the recipient
chThe character to display
Returns
1 on success, 0 on failure
int prof_chat_set_outgoing_char ( char *  barejid,
char *  ch 
)

Set the outgoing message prefix character for specified contact.

Parameters
barejidJabber ID of the recipient
chThe character to display
Returns
1 on success, 0 on failure
int prof_chat_set_titlebar_enctext ( char *  barejid,
char *  enctext 
)

Set the text to display in the titlebar encryption indicator for recipient.

Parameters
barejidJabber ID of the recipient
enctextThe text to display
Returns
1 on success, 0 on failure
int prof_chat_show ( char *  barejid,
char *  message 
)

Show a message in a chat window.

Parameters
barejidJabber ID of the recipient
messagethe message to print
Returns
1 on success, 0 on failure
int prof_chat_show_themed ( char *  barejid,
char *  group,
char *  item,
char *  def,
char *  ch,
char *  message 
)

Show a message in a chat window, using the specified theme, and prefix character Themes are specified in ~/.local/share/profanity/plugin_themes

Parameters
barejidJabber ID of the recipient
groupthe group name in the themes file or NULL
itemthe item name within the group or NULL
defdefault colour if the theme cannot be found
chThe character to prefix the message, or NULL for default behaviour
messagethe message to print
Returns
1 on success, 0 on failure
int prof_chat_unset_incoming_char ( char *  barejid)

Reset the incoming message prefix character for specified contact.

Parameters
barejidJabber ID of the recipient
Returns
1 on success, 0 on failure
int prof_chat_unset_outgoing_char ( char *  barejid)

Reset the outgoing message prefix character for specified contact.

Parameters
barejidJabber ID of the recipient
Returns
1 on success, 0 on failure
int prof_chat_unset_titlebar_enctext ( char *  barejid)

Let profanity decide what to show in the titlebar encryption indicator for recipient.

Parameters
barejidJabber ID of the recipient
Returns
1 on success, 0 on failure
void prof_completer_add ( const char *  key,
char **  items 
)

Add values to be autocompleted by Profanity for a command, or command argument. If the key already exists, Profanity will add the items to the existing autocomplete items for that key.

Parameters
keythe prefix to trigger autocompletion
itemsthe items to return on autocompletion
void prof_completer_clear ( const char *  key)

Remove all values from autocompletion for a command, or command argument.

Parameters
keythe prefix from which to clear the autocompletion items
void prof_completer_remove ( const char *  key,
char **  items 
)

Remove values from autocompletion for a command, or command argument.

Parameters
keythe prefix from which to remove the autocompletion items
itemsthe items to remove
void prof_cons_alert ( void  )

Highlights the console window in the status bar.

int prof_cons_bad_cmd_usage ( const char *const  cmd)

Show a message indicating the command has been called incorrectly.

Parameters
cmdthe command name with leading slash, e.g. "/say"
Returns
1 on success, 0 on failure
int prof_cons_show ( const char *const  message)

Show a message in the console window.

Parameters
messagethe message to print
Returns
1 on success, 0 on failure
int prof_cons_show_themed ( const char *const  group,
const char *const  item,
const char *const  def,
const char *const  message 
)

Show a message in the console, using the specified theme. Themes are specified in ~/.local/share/profanity/plugin_themes

Parameters
groupthe group name in the themes file
itemthe item name within the group
defdefault colour if the theme cannot be found
messagethe message to print
Returns
1 on success, 0 on failure
int prof_current_win_is_console ( void  )

Determine whether or not the Console window is currently focussed.

Returns
1 if the user is currently in the Console window, 0 otherwise.
void prof_disco_add_feature ( char *  feature)

Add a service discovery feature the list supported by Profanity. If a session is already connected, a presence update will be sent to allow any client/server caches to update their feature list for Profanity

Parameters
featurethe service discovery feature to be added
void prof_encryption_reset ( char *  barejid)

End any encrypted session with the specified user.

Parameters
barejidJabber ID of the recipient
void prof_filepath_completer_add ( const char *  prefix)

Add filepath autocompletion for a command, or command argument.

Parameters
prefixthe prefix from which filepath autocompletion will be triggered
char* prof_get_current_muc ( void  )

Retrieve the Jabber ID of the current room, when in a chat room window.

Returns
the Jabber ID of the current chat room e.g. "metalchat@conference.chat.org", or NULL if not in a chat room window.
char* prof_get_current_nick ( void  )

Retrieve the users nickname in a chat room, when in a chat room window.

Returns
the users nickname in the current chat room e.g. "eddie", or NULLL if not in a chat room window.
char** prof_get_current_occupants ( void  )

Retrieve nicknames of all occupants in a chat room, when in a chat room window.

Returns
nicknames of all occupants in the current room or an empty list if not in a chat room window.
char* prof_get_current_recipient ( void  )

Retrieve the Jabber ID of the current chat recipient, when in a chat window.

Returns
the Jabber ID of the current chat recipient e.g. "buddy@chat.org", or NULL if not in a chat window.
char* prof_get_room_nick ( const char *  barejid)

Retrieve current nickname used in chat room.

Parameters
barejidThe room's Jabber ID
Returns
Room nickname.
void prof_incoming_message ( char *  barejid,
char *  resource,
char *  message 
)

Trigger incoming message handling, this plugin will make profanity act as if the message has been received

Parameters
barejidJabber ID of the sender of the message
resourceresource of the sender of the message
messagethe message text
void prof_log_debug ( const char *  message)

Write to the Profanity log at level DEBUG.

Parameters
messageThe message to log
void prof_log_error ( const char *  message)

Write to the Profanity log at level ERROR.

Parameters
messageThe message to log
void prof_log_info ( const char *  message)

Write to the Profanity log at level INFO.

Parameters
messageThe message to log
void prof_log_warning ( const char *  message)

Write to the Profanity log at level WARNING.

Parameters
messageThe message to log
void prof_notify ( const char *  message,
int  timeout_ms,
const char *  category 
)

Send a desktop notification.

Parameters
messagethe message to display in the notification
timeout_msthe length of time before the notification disappears in milliseconds
categorythe category of the notification, also displayed
void prof_register_command ( const char *  command_name,
int  min_args,
int  max_args,
char **  synopsis,
const char *  description,
char *  arguments[][2],
char **  examples,
CMD_CB  callback 
)

Register a new command, with help information, and callback for command execution. Profanity will do some basic validation when the command is called using the argument range.

Parameters
command_namethe command name with leading slash, e.g. "/say"
min_argsminimum number or arguments that the command considers to be a valid call
max_argsmaximum number or arguments that the command considers to be a valid call
synopsiscommand usages
descriptiona short description of the command
argumentsargument descriptions
examplesexample usages
callbackThe CMD_CB function to execute when the command is invoked
void prof_register_timed ( TIMED_CB  callback,
int  interval_seconds 
)

Register a function that Profanity will call periodically.

Parameters
callbackThe TIMED_CB function to execute
interval_secondsthe time between each call to the function, in seconds
int prof_room_set_message_char ( char *  roomjid,
char *  ch 
)

Set the message prefix character for specified room.

Parameters
roomjidJabber ID of the room
chThe character to display
Returns
1 on success, 0 on failure
int prof_room_set_titlebar_enctext ( char *  roomjid,
char *  enctext 
)

Set the text to display in the titlebar encryption indicator for room.

Parameters
roomjidJabber ID of the room
enctextThe text to display
Returns
1 on success, 0 on failure
int prof_room_show ( char *  roomjid,
char *  message 
)

Show a message in a chat room window.

Parameters
barejidJabber ID of the room
messagethe message to print
Returns
1 on success, 0 on failure
int prof_room_show_themed ( char *  roomjid,
char *  group,
char *  item,
char *  def,
char *  ch,
char *  message 
)

Show a message in a chat room window, using the specified theme, and prefix character Themes are specified in ~/.local/share/profanity/plugin_themes

Parameters
barejidJabber ID of the room
groupthe group name in the themes file or NULL
itemthe item name within the group or NULL
defdefault colour if the theme cannot be found
chThe character to prefix the message, or NULL for default behaviour
messagethe message to print
Returns
1 on success, 0 on failure
int prof_room_unset_message_char ( char *  roomjid)

Reset the message prefix character for specified room.

Parameters
roomjidJabber ID of the room
Returns
1 on success, 0 on failure
int prof_room_unset_titlebar_enctext ( char *  roomjid)

Let profanity decide what to show in the titlebar encryption indicator for room.

Parameters
roomjidJabber ID of the room
Returns
1 on success, 0 on failure
void prof_send_line ( char *  line)

Send a line of input to Profanity to execute.

Parameters
linethe line to send
int prof_send_stanza ( char *  stanza)

Send an XMPP stanza

Parameters
stanzaan XMPP stanza
Returns
1 if the stanza was sent successfully, 0 otherwise
int prof_settings_boolean_get ( char *  group,
char *  key,
int  def 
)

Get a boolean setting Settings must be specified in ~/.local/share/profanity/plugin_settings

Parameters
groupthe group name in the settings file
keythe item name within the group
defdefault value if setting not found
Returns
the setting, or default value
void prof_settings_boolean_set ( char *  group,
char *  key,
int  value 
)

Set a boolean setting Settings must be specified in ~/.local/share/profanity/plugin_settings

Parameters
groupthe group name in the settings file
keythe item name within the group
valuevalue to set
int prof_settings_int_get ( char *  group,
char *  key,
int  def 
)

Get an integer setting Settings must be specified in ~/.local/share/profanity/plugin_settings

Parameters
groupthe group name in the settings file
keythe item name within the group
defdefault value if setting not found
Returns
the setting, or default value
void prof_settings_int_set ( char *  group,
char *  key,
int  value 
)

Set an integer setting Settings must be specified in ~/.local/share/profanity/plugin_settings

Parameters
groupthe group name in the settings file
keythe item name within the group
valuevalue to set
char* prof_settings_string_get ( char *  group,
char *  key,
char *  def 
)

Get a string setting Settings must be specified in ~/.local/share/profanity/plugin_settings

Parameters
groupthe group name in the settings file
keythe item name within the group
defdefault value if setting not found
Returns
the setting, or default value
void prof_settings_string_list_add ( char *  group,
char *  key,
char *  value 
)

Add an item to a string list setting Settings must be specified in ~/.local/share/profanity/plugin_settings If the list does not exist, a new one will be created with the element added

Parameters
groupthe group name in the settings file
keythe item name within the group
valueitem to add
int prof_settings_string_list_clear ( char *  group,
char *  key 
)

Remove all items from a string list setting Settings must be specified in ~/.local/share/profanity/plugin_settings

Parameters
groupthe group name in the settings file
keythe item name within the group
Returns
1 if the list was cleared, 0 if the list does not exist
char** prof_settings_string_list_get ( char *  group,
char *  key 
)

Get a string list setting Settings must be specified in ~/.local/share/profanity/plugin_settings The string list setting items are separated by semicolons.

Parameters
groupthe group name in the settings file
keythe item name within the group
Returns
the list setting
int prof_settings_string_list_remove ( char *  group,
char *  key,
char *  value 
)

Remove an item from a string list setting Settings must be specified in ~/.local/share/profanity/plugin_settings

Parameters
groupthe group name in the settings file
keythe item name within the group
valueitem to remove
Returns
1 if the item was removed, or is not in the list, 0 if the list does not exist
void prof_settings_string_set ( char *  group,
char *  key,
char *  value 
)

Set a string setting Settings must be specified in ~/.local/share/profanity/plugin_settings

Parameters
groupthe group name in the settings file
keythe item name within the group
valuevalue to set
void prof_win_create ( PROF_WIN_TAG  win,
WINDOW_CB  input_handler 
)

Create a plugin window.

Parameters
winThe PROF_WIN_TAG used to refer to the window
input_handlerThe WINDOW_CB function to call when the window receives input
int prof_win_exists ( PROF_WIN_TAG  win)

Determine whether or not a plugin window currently exists for PROF_WIN_TAG.

Parameters
winthe PROF_WIN_TAG used when creating the plugin window
Returns
1 if the window exists, 0 otherwise
int prof_win_focus ( PROF_WIN_TAG  win)

Focus plugin window.

Parameters
winthe PROF_WIN_TAG of the window to focus
Returns
1 on success, 0 on failure
int prof_win_show ( PROF_WIN_TAG  win,
char *  message 
)

Show a message in the plugin window.

Parameters
winthe PROF_WIN_TAG of the window to display the message
messageThe message to print
Returns
1 on success, 0 on failure
int prof_win_show_themed ( PROF_WIN_TAG  tag,
char *  group,
char *  key,
char *  def,
char *  message 
)

Show a message in the plugin window, using the specified theme. Themes are specified in ~/.local/share/profanity/plugin_themes

Parameters
tagThe PROF_WIN_TAG of the window to display the message
groupthe group name in the themes file
keythe item name within the group
defdefault colour if the theme cannot be found or NULL
messagethe message to print
Returns
1 on success, 0 on failure